Advanced Search

Results 1 to 3 of 3

Thread: Can This Be Optimized?

  1. #1
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    130
    Thanks
    49
    Thanked 0 Times in 0 Posts

    Default Can This Be Optimized?

    I want to open "www.urlname.com" in a new window. The code that follows (extraneous stuff excised) works. That is a virtue the value of which is not to be underestimated. Still, a couple of things puzzle me. One is that in the html, the url is specified twice. Also, I do not understand what the "return false" accomplishes. I am hoping someone can take me by the hand and advise whether a better mousetrap stares me in the face.

    Best to all,

    A.

    HTML Code:
    <head>
    <title>bigtitle</title>
    <script language="JavaScript" type="text/javascript" src="js/popwin.js"></script>
    </head>
    <body>
    .
    .
    .
    <a href="http://www.urlname.com" target="_blank" onclick="popwin('http://www.urlname.com'); return false">Big Link</a>
    .
    .
    .
    </body>
    Code:
    function popwin(file) {
     window.open(file,'','toolbar=no,left=20,top=20,status=no,width=850,height=500,scrollbars=yes,directories=no,location=no,resizable=yes,menubar=no');
    }
    Last edited by traq; 11-24-2012 at 07:38 PM. Reason: formatting: please use the forum's BBCode tags

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,707
    Thanks
    2
    Thanked 388 Times in 383 Posts

    Default

    you could use

    Code:
    <a href="http://www.urlname.com" target="_blank" onclick="popwin(this.href); return false">Big Link</a>
    the return false is to stop the link working when clicked
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. #3
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    130
    Thanks
    49
    Thanked 0 Times in 0 Posts

    Default

    Yes, that is what return false generally does. However, it does not prevent the link from working here, and I actually want the link to fire every time it is clicked. My impression is that the return false here is superfluous and does nothing. Before removing it, however, I seek the counsel of scriptists more seasoned than I. (In case y'all did not figure it out, I did not write the original script.)

Similar Threads

  1. Dynamic DriveŠ Marquee script optimized for HTML5
    By shotdsherrif in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 04-11-2011, 10:29 PM
  2. How To Optimized A Flash?
    By FrisArvz in forum Flash
    Replies: 2
    Last Post: 11-24-2009, 06:40 PM

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
  •