SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: Help needed

  1. #1
    SitePoint Member
    Join Date
    Jan 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help needed

    Can someone help me with a simple JS code, since I am new with it, but I need it for my website. There is incompatibility with this two lines

    <a href="en.htm" onclick="return hs.htmlExpand(this, { objectType: 'ajax'} )">
    <a href="img/02.jpg" class="highslide" onclick="return hs.expand(this)">

    First one is used for pop-up window when someone press an icon for changing language on the website, second one is in other part of the html code and it is used for the gallery. If I remove the first line, the second works perfectly.
    Thanks in advance
    PS: I can post the entire code if needed

  2. #2
    SitePoint Addict sdleihssirhc's Avatar
    Join Date
    Feb 2009
    Posts
    387
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    All <a> tags need to be closed, so just based on the HTML you posted, I imagine that the top one is being left open, the browser thinks that the second one is a child of the first, and that messes with the JS. But that's a wild guess. If you link to a live example, I could investigate a little more thoroughly. (And if you were feeling particularly awesome, you could link to a version that has the first line, and then another version that doesn't, so that we could compare.)
    Last edited by sdleihssirhc; Jan 27, 2012 at 14:10. Reason: *snip*
    I'm the web overlord for Graphic Business Systems

  3. #3
    SitePoint Member
    Join Date
    Jan 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Give few minutes to make the links and upload them, it's not the <a> tag, cause it's closed on proper place. The code works fine on the other pages, but on this one there is js gallery and that's why it has problem, something with the java that I use for the gallery is messing up.

  4. #4
    SitePoint Member
    Join Date
    Jan 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, here is the link: http://www.eccofarm.com/js
    So, on the first page, I've put the js code for the flags of English language and Greek language. So far so good, works fine.
    On page Галерия(Gallery, the one before the last in the menu) I've tried to do the same for the English language button. So I just copied the code, that works fine on the first page. And it's not working fine;

    <a href="indexEN.html"> <a href="en.htm" onclick="return hs.htmlExpand(this, { objectType: 'ajax'} )">
    <img style="position: absolute; top:5px; left: 1190px;" title="English" src="images/flags/en.png"></a></a>

    It's like the browser doesn't read this code: <a href="en.htm" onclick="return hs.htmlExpand(this, { objectType: 'ajax'} )">
    It's just redirecting me to page indexEN.html(it should show as pop-up)
    Any idea?

  5. #5
    SitePoint Member
    Join Date
    Jan 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, I have made bad positioning for the flags, don't pay much attention, will fixed it later.

  6. #6
    SitePoint Addict sdleihssirhc's Avatar
    Join Date
    Feb 2009
    Posts
    387
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Okay, I think I figured it out.

    The "htmlExpand" method is only created in the "highslide-with-html.js" file. However, all of your code in "highslide-with-html.js" is wrapped in a giant if block:

    Code JavaScript:
    if (!hs) {
        // create the object and all of its methods,
        // including htmlExpand
    }

    But on your gallery page, the "highslide-with-gallery.js" script runs first. It creates an "hs" object, so none of the code in "highslide-with-html.js" gets executed.

    The quickest fix would be to add another if in your "highslide-with-html.js" script:

    Code JavaScript:
    if (!hs) {
        // create the entire object
     
    } else if (!hs.htmlExpand) {
        // the object exists, but not the method you want
        // so just create the method
    }

    However, you'd probably be better served in the long term by refactoring all of your scripts. I imagine that if one method got left out, others did as well. Who knows how many bugs you'd have to keep chasing down...
    I'm the web overlord for Graphic Business Systems

  7. #7
    SitePoint Member
    Join Date
    Jan 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much dude.
    This pop-up windows will stay until i translate the pages in the different languages. May be you can advice me to use something else to show a warning message, which will not be in conflict with the JS Gallery?

  8. #8
    SitePoint Member
    Join Date
    Jan 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never mind, I figured it out with new JS code. Will posted later if someone wants to take a look.
    Greetings and thank you very much.

  9. #9
    SitePoint Member
    Join Date
    Jan 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •