Results 1 to 3 of 3

Thread: Please help..This is the last piece of code to get working

  1. #1
    Join Date
    Jul 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Please help..This is the last piece of code to get working

    Thanks to Gary Newell for the help with the popups...I have it working .."almost"...if i call the popup from an image it has focus and is on top..if I click another image the new url loads and focus stays on top..this is all perfect so far but 1 problem left....if i close the popup after calling it from one of the images and then click another image to popup the window I get an Script error
    ..says line 17
    charactor 4
    unspecified error
    code 0
    so it looks to see if a window is open and if so load new url and give focus. but if you pop one up then close it yourself and click another image it errors. If you refresh the page it works ok again unless you close the popup window.
    Here is a link to the page

    http://www.lhfcorp.com/wood/rightlaminate.html when you get there click an image and popup will work...click another image and popup will load new url an get focus...now close the popup and try clicking any image again..no popup and error occurs.

    ...can anyone help...this is thre last piece of the site to get working..

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,127
    Thanks
    44
    Thanked 3,228 Times in 3,189 Posts
    Blog Entries
    12

    Default

    First of all, things are a bit ambiguous. You have both a window name and a variable name of 'window1'. Another thing, you seem to not realize that the browser is perfectly capable of checking to see if a window named window1 already exists and, if so, replacing its contents with the new url and, if not, opening it first. The browser also has no problem in giving focus to a window it has just opened. One more thing, the language attribute for the script tag is deprecated, don't use it. With all this in mind, your script can be simplified to:
    Code:
    <script type="text/javascript"> 
    function showit(txt) 
    { 
    window1 = window.open(txt,"window1","width=750,height=400,left=115,top=130,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes");     
    window1.focus(); 
    } 
    </script>
    Also, the links like this one:
    HTML Code:
    <a href=# onclick="showit('http://www.columbiaflooring.com')">
    should probably be:
    HTML Code:
    <a href="http://www.columbiaflooring.com" onclick="showit(this.href);return false;">
    to prevent unwanted windows from opening and/or page reloads from happening. And to give non javascript enabled browsers something to see.
    Last edited by jscheuer1; 07-02-2005 at 06:20 PM. Reason: add info
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,127
    Thanks
    44
    Thanked 3,228 Times in 3,189 Posts
    Blog Entries
    12

    Default

    One more thing, unless this page is normally in a frameset that includes a frame named "right", get rid of this:
    HTML Code:
    <base target="right">
    or, considereing only non javascript enabled browsers will use it (even in a frameset), change it to:
    Code:
    <base target="_blank">
    Last edited by jscheuer1; 07-03-2005 at 11:40 AM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •