SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot TCJeter's Avatar
    Join Date
    Jun 2002
    Location
    Anchorage, AK
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    overLIB tweaking..not covered in Bosrup's FAQ

    Hey all, I'm trying to do a little tweaking on the overLIB script to get a popup window (from a link within the popup <div>) to open to a specific size. Can anyone help with the syntax?

    I'm not extremely adept with javascript, but here goes...
    Currently, on one of our company's sites I use the format below to get a popup window from a text link:
    Code:
    <script language="JavaScript">
    
    function MM_openBrWindow(theURL,winName,features) { //v2.0
      window.open(theURL,winName,features);
    }
    </script>
    <a href="/pop_ups/1301.htm" onClick="MM_openBrWindow('/pop_ups/1301.htm','Some Option','width=500,height=350'); return false;" target="_blank">Text Link Here</a>
    Now, I have the overLIB popup menus show for links on an image map like this:
    Code:
    <area shape="rect" coords="-1,-1,111,31" href="javascript:void(0);" 
    alt="Some Option" onclick="return overlib('<b>Window Title</b><br><a 
    href=\'/pop_ups/1301.htm\'>Link #1</a><br><a  href=\'/pop_ups/1302.htm\'>Link #2</a', STICKY, CAPTION, 'Some Option', CENTER);" onmouseout="nd();">
    Sooooo...., I want to combine them so that I have something like this:
    Code:
      <area shape="rect" coords="210,140,308,167" href="javascript:void(0);" alt="Some Options" onclick="return overlib('<b>Window Title</b><br><a 
    href=\'../pop_ups/1301.htm\' \'onClick=\'MM_openBrWindow
    (\'../pop_ups/1301.htm\',\'Link #1\',\'width=500,height=350\'); return false;\' 
    target=\'_blank\'>Link #1</a><br><a href=\'../pop_ups/1302.htm\' 
    \'onClick=\'MM_openBrWindow(\'../pop_ups/1302.htm\',\'Link #2
    \',\'width=500,height=350\'); return false;\' target=\'_blank\'>Link #2</a>', STICKY, CAPTION, 'Some Options', CENTER);" onmouseout="nd();">
    This does function without errors, but the window does NOT open to the specified size. I'm assuming that the onClick event handler won't operate inside of another onClick event? Is anyone familiar enough with overLIB to help out here?

    Thanks in advance!
    -TC

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi TC,

    I've never used overLIB, but I'm having a look at your code. First let me point out that your 'window names' (second argument to MM_openBrWindow) are invalid (I don't know yet if this is causing the problem). According to the reference: "windowName can contain only alphanumeric or underscore (_) characters."

  3. #3
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Got it

    It's confusing when there are different levels of nested quotes, so I simplified it as much as possible by moving the string into a function. I don't know if that's an option for you - but it simplifies the quotes, and it works for me Here's what I used to debug this:
    Code:
    <html>
    <head>
    <script>
    var STICKY='STICKY', CAPTION='CAPTION', CENTER='CENTER';
    function MM_openBrWindow(theURL,winName,features) { //v2.0
      window.open(theURL,winName,features);
    }
    function nd() { /* stub */ }
    function overlib()
    {
      var s = '';
      for (var i=0; i<arguments.length; ++i) {
        s += 'arg' + i + ': ' + arguments[i] + '\n';
      }
      // assign arg0 to element d1 for testing the links
      document.getElementById('d1').innerHTML = arguments[0];
      // display all args to this function to help debug nested quotes
      alert(s);
      return false;
    }
    function overlib_1()
    {
      return overlib("<b>Window Title</b><br><a href='../pop_ups/1301.htm' onClick=\"MM_openBrWindow('../pop_ups/1301.htm','Link1','width=500,height=350'); return false;\" target='_blank'>Link #1</a><br><a href='../pop_ups/1302.htm' onClick=\"MM_openBrWindow('../pop_ups/1302.htm','Link2','width=350,height=500'); return false;\" target='_blank'>Link #2</a>", STICKY, CAPTION, 'Some Options', CENTER);
    }
    </script>
    </head>
    <body>
    
    <map NAME="clientsidemap">
    <area 
      shape="rect" 
      coords="0,0,100,100" 
      href="javascript:void(0);" 
      alt="Some Options" 
      onmouseout="nd();"
      onclick="return overlib_1()"
    </map>
    
    <a HREF=""> <img SRC="image.gif" ISMAP USEMAP="#clientsidemap" width='100' height='100'> </a>
    
    <div id='d1'></div>
    
    </body>
    </html>

  4. #4
    SitePoint Zealot TCJeter's Avatar
    Join Date
    Jun 2002
    Location
    Anchorage, AK
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    live example

    Mike - thanks for your input, although I couldn't get this to do what I needed. It may be faulty implementation on my part, ut I'm sure a live example would help you see what I need to make the script do.

    If you check out this link, you can see what happens on the page. Click any of the cities to see (on a side note, I can't get the pointy-finger icon to show for these links...would you know anything about that?). I need to get the links (inside the overLIB popup) to launch a new window - which they do - but they need to be the assigned size. Preferrably (sp?) 500W X 350H.

    Does this make sense?

    Again, thanks.
    -TC

  5. #5
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's the Fairbanks link, using the same syntax as in my previous post:
    Code:
    <html>
    <head>
    <script>
    function fairbanks_click()
    {
      return overlib("<b>Fairbanks, AK</b><br><a href='../pop_ups/1344.htm' onClick=\"MM_openBrWindow('../pop_ups/1344.htm','Sternwheeler_Cruise_Riverboat_Discovery','width=500,height=350'); return false;\" target='_blank'>Sternwheeler Cruise - Riverboat Discovery</a><br><a href='../pop_ups/1340.htm' 'onClick=\"MM_openBrWindow('../pop_ups/1340.htm','Arctic_Circle_Fly_Drive_Adventure','width=500,height=350'); return false;\" target='_blank'>Arctic Circle Fly-Drive Adventure</a>", STICKY, CAPTION, 'Fairbanks', CENTER);
    }
    </script>
    </head>
    <body>
    <map name="FBX" id="FBX">
      <area shape="rect" coords="210,140,308,167" href="javascript:void(0);" alt="Fairbanks Tours" onclick="return fairbanks_click()" onmouseout="nd()">
    </map>
    </body>
    </html>
    Note that I changed the window names, for example...
    from: Sternwheeler Cruise - Riverboat Discovery
    to: Sternwheeler_Cruise_Riverboat_Discovery

  6. #6
    SitePoint Zealot TCJeter's Avatar
    Join Date
    Jun 2002
    Location
    Anchorage, AK
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    window size

    Thanks for clarifying, Mike. I did get it to work, but the 'tour description' popup windows are still opening to a standard size. If you take a look at the FBX link again, you can see I've modified the code as you suggested but the windows from those links don't re-adjust to the specified W X H (450 X 350).

    But, the way you've organized it in the example is great!
    I don't want to hog your time, but any more help would be greatly appreciated.

    Thanks,
    -TC

  7. #7
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi TC,

    Three things...

    1) When copying code from forums always look for changes like this:

    The forum code changed "javascript" to "java_script_" (for security issues). Or you may see it changed to "java script".

    2) I think you left out the function MM_openBrWindow.

    3) I had a syntax error in my last post. Sorry about that (but you should always double-check me ).
    Code:
    function fairbanks_click()
    {
      return overlib("<b>Fairbanks, AK</b><br><a href='../pop_ups/1344.htm' onClick=\"MM_openBrWindow('../pop_ups/1344.htm','Sternwheeler_Cruise_Riverboat_Discovery','width=450,height=350'); return false;\" target='_blank'>Sternwheeler Cruise - Riverboat Discovery</a><br><a href='../pop_ups/1340.htm' onClick=\"MM_openBrWindow('../pop_ups/1340.htm','Arctic_Circle_Fly_Drive_Adventure','width=500,height=350'); return false;\" target='_blank'>Arctic Circle Fly-Drive Adventure</a>", STICKY, CAPTION, 'Fairbanks', CENTER);
    }
    Very nice site! Good luck with it.

  8. #8
    SitePoint Zealot TCJeter's Avatar
    Join Date
    Jun 2002
    Location
    Anchorage, AK
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks....

    Mike -
    Thanks for the help. Yes, I did get in a hurry and just slap it in without double-checking...just got a little excited

    I did nix the MM function for some reason, and then forgot to put it back in. I'll go back and review my work and double-check for errors - then see if it will work.

    Thanks for the pointers so far,
    -TC


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
  •