- Code: Select all
<script type="text/javascript">
hs.addEventListener(window, "load", function() {
hs.expand(null, {
src: 'image.jpg'
});
});
</script>
Running hs.expand like this without an anchor works in Highslide since version 4.0.7.
A second method - if you want to open an existing anchor - is to assign an id to it then virtually click it.
1) Define the opening anchor like you normally would, and assign an id to it.
Image expander:
- Code: Select all
<a id="autoload" href="img.jpg" onclick="return hs.expand(this)">
Alternatively, a HTML expander:
- Code: Select all
<a id="autoload" href="page.htm" onclick="return htmlExpand(this, { objectType: AJAX })">
2) In the head section of your page, or in a separate JavaScript file, define an event handler for the page onload event. This code must be placed after the <script> tag where the highslide.js file is included. Highslide has a built-in function called addEventListener that you should use to prevent crashes with other onload handlers.
- Code: Select all
<script type="text/javascript">
hs.addEventListener(window, "load", function() {
// click the element virtually:
document.getElementById("autoload").onclick();
});
</script>