SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Location
    New Zealand
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript popup errors

    Hi all. I've inherited a site with frames made in Cold Fusion which includes a navigation bar in the left frame. Two buttons open to javascript popups rather than changing the content of the main frame. The problem is that when you click one of these buttons the content of the frame which held the navigation bar disappears and is left with the word "false" - not very user friendly navigation I'd say

    Here is the code of the popup.js file

    /*
    Language: CS Javascript
    Name: popup
    Description:
    Pops up a window of specified dimensions and disables href where appropriate to avoid
    double window creation. Therefore safe to use hrefs in an a tag in case of no javascript.
    In case of no dimensions specified, it uses a percentage of the screen size.
    */
    var widthPercent=0.6;
    var heightPercent=0.95;

    function popup(url, title, w, h, scrollbars, resizable) {
    if (scrollbars == null)
    scrollbars = true;
    if (resizable == null)
    resizable = true;
    var bAgent = window.navigator.userAgent;
    var bAppName = window.navigator.appName;
    if (!w) {
    if (document.body) {
    w=document.body.clientWidth*widthPercent;
    h=document.body.clientHeight*heightPercent;
    }
    else {
    if (window.innerWidth) {
    w=window.innerWidth*widthPercent;
    h=window.innerHeight*heightPercent;
    }
    else {
    w=300;
    h=400;
    }
    }
    }
    var w = window.open(url, title, 'width='+w+',height='+h+',toolbar=no,menubar=no,location=no,scrollbars='+(scrollbars?"yes":"no")+',resizable='+(resizable?"yes":"no"));
    w.focus();
    if ((bAppName.indexOf("Explorer") >= 0) && (bAgent.indexOf("Mozilla/3") >= 0) && (bAgent.indexOf("Mac") >= 0))
    return true; // do follow link
    else return false; // don't follow link
    }

    I don't know much about javascript and would be grateful for any help.
    Thanks, Sheryll.
    <help>StIcKs</help>

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you neva called the function

    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <
    html>
    <
    head>
    <
    title>Page title</title>
    </
    head>
    <
    body>
    <
    script type="text/javascript">
    <!--
    /* 
    Language: CS Javascript 
    Name: popup 
    Description: 
    Pops up a window of specified dimensions and disables href where appropriate to avoid 
    double window creation. Therefore safe to use hrefs in an a tag in case of no javascript. 
    In case of no dimensions specified, it uses a percentage of the screen size. 
    */ 
    var widthPercent=0.6
    var 
    heightPercent=0.95

            function 
    popup(urltitlewhscrollbarsresizable)
            { 
                 if (
    scrollbars == nullscrollbars true
                 if (
    resizable == nullresizable true

                 var 
    bAgent window.navigator.userAgent
                 var 
    bAppName window.navigator.appName

                 if (!
    w)
                 { 
                      if (
    document.body)
                     { 
                          
    w=document.body.clientWidth*widthPercent
                         
    h=document.body.clientHeight*heightPercent;
                     }
                 else
                 { 
                    if (
    window.innerWidth)
                    { 
                        
    w=window.innerWidth*widthPercent
                        
    h=window.innerHeight*heightPercent
                     }
                     else
                     {
                      
    w=300;
                        
    h=400
                     }
                  }
            }
            
    var 
    window.open(urltitle'width='+w+',height='+h+',toolbar=no,menubar=no,location=no,scrollbars='+(scrollbars?"yes":"no")+',resizable='+(resizable?"yes":"no")); 
    w.focus();

    if ((
    bAppName.indexOf("Explorer") >= 0) && (bAgent.indexOf("Mozilla/3") >= 0) && (bAgent.indexOf("Mac") >= 0)) return true// do follow link 
    else return false// don't follow link 
    }

    popup('http://www.sitepoint.com''mywindow'250250'yes''yes')

    // -->
    </script>

    </body>
    </html> 

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Location
    New Zealand
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Andrew, thanks for the reply. I think I might not have explained my problem very well When you click one of the buttons that open the popup - the popup works but the contents of the frame that held the buttons etc disappears. User then left with contents of 'main' frame, popup window, but no navigation

    The code of the frame that calls the popup, in case it helps, is:-

    <cfsetting showdebugoutput="no">

    <cfset tag = "_tags/display_button.cfm">
    <cfmodule template="#tag#" return="bhome" href="index.cfm" a_attributes="onlick=activate('home.jpg');" target="_top" base="/_images/nav/" file="home_1.gif,home_2.gif"/>
    <cfmodule template="#tag#" return="bproduct_suite" href="product_suite.cfm" a_attributes="onclick=activate('product_suite.jpg');" target="main" base="/_images/nav/" file="product_suite_1.gif,product_suite_2.gif"/>
    <cfmodule template="#tag#" return="bnews_info" alt="latest travel news" href="news_info.cfm" a_attributes="onclick=activate('news_info.jpg');" target="main" base="/_images/nav/" file="news_info_1.gif,news_info_2.gif"/>
    <cfmodule template="#tag#" return="brest" href="travellers_rest.cfm" a_attributes="onclick=activate('travellers_rest.jpg');" target="main" base="/_images/nav/" file="rest_1.gif,rest_2.gif"/>
    <cfmodule template="#tag#" return="babout" href="about_us.cfm" a_attributes="onclick=activate('about_us.jpg');" target="main" base="/_images/nav/" file="about_us_1.gif,about_us_2.gif"/>

    <cfmodule template="#tag#" return="bcontact" href="contact_us.cfm" a_attributes="onclick=activate('contact_us.jpg');" target="main" base="/_images/nav/" file="contact_1.gif,contact_2.gif"/>

    <cfmodule template="#tag#" return="bmessages" href="javascriptopup('/messages.cfm', 'messages', #popup_width#, #popup_height#);" base="/_images/nav/" file="messages_1.gif,messages_2.gif"/>

    <cfmodule template="#tag#" return="bsignup" href="javascriptopup('/signup.cfm', 'signup', #popup_width#, #popup_height#);" base="/_images/nav/" file="signup_1.gif,signup_2.gif"/>

    <cfmodule template="#tag#" return="bmembers" a_attributes="onclick=activate('members.jpg');" href="#adagiohttps#/members/index.cfm" target="main" base="/_images/nav/" file="members_1.gif,members_2.gif"/>
    <cfoutput>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <html>
    <head>
    <title>Untitled</title>
    <link type='text/css' res='stylesheet' href='/_clientside/style.css'>
    <script language='JavaScript' src='/_clientside/popup.js'></script>
    <script language='JavaScript'>
    function swap(name, number) {
    document.images[name].src = "/_images/nav/"+name+"_"+number+".gif";
    }
    function activate(imgname) {
    document.images.navimg.src = '/_images/nav/'+imgname;
    }
    </script>
    </head>

    <body topmargin='0' leftmargin='0'>
    <img name='navimg' src="/_images/nav/product_suite.jpg" alt="" border="0">
    <div align='center'>
    <table border='0' cellpadding='0' cellspacing='0' >
    <tr><td><img src='/_images/spacer.gif' width='1' height='2'></td></tr>
    <tr><td title='Home'>#bhome#</td></tr>
    <tr><td><img src='/_images/spacer.gif' width='1' height='2'></td></tr>
    <tr><td>#bproduct_suite#</td></tr>
    <tr><td><img src='/_images/spacer.gif' width='1' height='2'></td></tr>
    <tr><td>#bnews_info#</td></tr>
    <tr><td><img src='/_images/spacer.gif' width='1' height='2'></td></tr>
    <tr><td>#brest#</td></tr>
    <tr><td><img src='/_images/spacer.gif' width='1' height='2'></td></tr>
    <tr><td>#babout#</td></tr>
    <tr><td><img src='/_images/spacer.gif' width='1' height='2'></td></tr>
    <tr><td>#bcontact#</td></tr>
    <tr><td><img src='/_images/spacer.gif' width='1' height='2'></td></tr>
    <tr><td>#bmessages#</td></tr>
    <tr><td><img src='/_images/spacer.gif' width='1' height='2'></td></tr>
    <tr><td>#bsignup#</td></tr>
    <tr><td><img src='/_images/spacer.gif' width='1' height='2'></td></tr>
    <tr><td>#bmembers#</td></tr>
    </table>
    </div>
    </body>
    </html>
    </cfoutput>

    Thanks again, Sheryll.
    <help>StIcKs</help>


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
  •