1

I'm calling a utility called Highslide in a javascript function. Embedding the whole thing in the link like this works fine:

<a href="http://localhost/theopscompany-local/test-page-1/" onclick = "return hs.htmlExpand(this, { 
            objectType: 'ajax', width: 400, 
            headingEval: 'this.a.title', wrapperClassName: 'titlebar' }     )">highslide test link1</a>

However, placing said code in a function and calling it via onclick like below doesn't work. I've put it through jsfiddle and Firebug for syntax and all looks fine, but it just doesn't fire the Highslide code for some reason. The linked page is loaded normally instead.

<a href="http://localhost/theopscompany-local/test-page-1/" onclick = "highslideview2();">highslide test link2</a>
<script type="text/javascript">
function highslideview2() {
    return hs.htmlExpand(this, { 
        objectType: 'ajax', 
        headingEval: 'this.a.title', wrapperClassName: 'titlebar' });}
</script>

I know this is likely a very simple thing, so I apologize if it's below the level of the usual question, but I'm stumped and can't see why this doesn't work. The purpose is to a)clean up the HTML links and b) let me call different Highslide configurations for different types of links, so it's important enough to pursue.

Thanks in advance for any help!

2 Answers 2

1

The return value is now the result of the code executed within highslideview2() and not the function run when the onclick handler is fired. Adding the return back into the inline onclick attribute should fix it.

<a href="http://localhost/theopscompany-local/test-page-1/" onclick = "return highslideview2(this)">highslide test link2</a>
<script type="text/javascript">
function highslideview2(e) {
    return hs.htmlExpand(e, { 
        objectType: 'ajax', 
        headingEval: 'e.a.title', wrapperClassName: 'titlebar' });}
</script>
Sign up to request clarification or add additional context in comments.

4 Comments

No joy Emissary :( I'm wondering if the function should still be referencing "this" when in a script, or do I need to pass the link to it instead for it to work?
@Dains - You're correct, sorry I missed that in haste (obviously I can't test the code) - you can give your new function a parameter though and pass this to it. I've updated the code above.
I also edited headingEval - I'm not sure what exactly is happening with this code and whether that needed changing.
Woohoo works perfectly Emissary! Thank you for the help. Re the utility, it's an all-in-one JS windowizer you can find at highslide.com if you'd like to check it out. Aside from my ignorance in how to activate it properly, it's saving a lot of custom JS programming for the UI features I need.
0

Try this

<a href="http://localhost/theopscompany-local/test-page-1/" onclick = "highslideview2()">highslide test link2</a>
<script type="text/javascript">
function highslideview2() {
    return hs.htmlExpand(this, { 
        objectType: 'ajax', 
        headingEval: 'this.a.title', wrapperClassName: 'titlebar' });}
</script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.