8 January 2008 5 comments JavaScript
This blog post is 15 years old! Most likely, its content is outdated. Especially if it's technical.
If you use the wonderful Javascript library jQuery and the wonderful (standalone) Javascript plugin Highslide JS of recent version you should be aware of something.
As of recent versions of Highlide the way the Expander
function works is that it looks at an element's onclick
attribute and not it's attached events which means that if a DOM element has the event but not the attribute you get a Javascript error. In older versions of Highslide you were able to do this:
$('a.highslide').click(function() {
return hs.expand(this, options);
});
But that's no longer working since the attribute isn't set. Here's the new way of doing it:
$('a.highslide').each(function() {
this.onclick = function() {
return hs.expand(this, options);
};
});
- Previous:
- The Love Mattress 6 January 2008
- Next:
- input/textarea switcher with jQuery 11 January 2008
- Related by category:
- How to "onchange" in ReactJS 21 October 2015 JavaScript
- To then() or to success() in AngularJS 27 November 2014 JavaScript
- How to throttle AND debounce an autocomplete input in React 1 March 2018 JavaScript
- How to create-react-app with Docker 17 November 2017 JavaScript
- Display current React version 7 January 2018 JavaScript
- Related by keyword:
- Difference between $.data('foo') and $.attr('data-foo') in jQuery 10 June 2012
- From jQuery to Cash 18 June 2019
- How to fadeIn and fadeOut like jQuery but with Cash 24 August 2021
- Why I gave up on JQuery UI's autocomplete 20 October 2010
- Some tips on learning React 4 August 2015
Hi Peter!
I would like to call up Highslide for every markup putting this script in the header...but it doesn't work! Could you maybe help? Thank you!! ~Lukas
<script type="text/javascript">
$('a').each(function(){
this.onclick = function() {
return hs.htmlExpand(this, { objectType: 'iframe' } );
});
</script>
I think there's a forum on the Highslide website. Ask there.
Hi, Lukas!
Try putting that script in the body of the document.
//or just use it like this ;)
$(document).ready(function() {
$('a.highslide').each(function() {
this.onclick = function() {
return hs.expand(this);
};
});
});
i want to show pdf file in high slide getting pdf from database through ajax .