SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Window.open Not woking in safari(its very urgent)

    Hi:

    1 I am using javascript window.open() method to open new window, it works well inIE,Firefox but not working in safari.

    2 I have problem on firefox, image control never displays image in firefox.I have mentioned the code below.Can any one send me suggestions to solve these issues

    Javascript code:

    <html>
    <head>


    </head>
    <body>
    <a href="javascript:window.open('getkeycode.html','null','height=500,width=500,status=no, toolbar=no,menubar=no,location=no')">
    <img id="image" height="200" width="200" alt="Hi" src="URL">
    </a>

    </body>

    </html>


    Thanks

  2. #2
    SitePoint Evangelist
    Join Date
    Jul 2007
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It works in Safari 3.1.2 on Mac OS 10.5

  3. #3
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by suresh_dotnet View Post
    <a href="javascript:window.open('getkeycode.html','null','height=500,width=500,status=no, toolbar=no,menubar=no,location=no')">
    <img id="image" height="200" width="200" alt="Hi" src="URL">
    </a>
    This is not the cross-browser way of opening a new window.
    Here is the solution.
    HTML Code:
    <a href="getkeycode.html" onclick="javascript:window.open('getkeycode.html','null','height=500,width=500,status=no, toolbar=no,menubar=no,location=no');return false">Link TEXT or IMAGE HERE</a>

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,832
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    You don't need a label inside the onclick. The onclick already identifies that it is JavaScript. There are also a couple of other changes you can make that will make the onclick code more portable so that you don't need to change it if you have multiple links that you want to use it with.

    HTML Code:
    <a href="getkeycode.html"
    onclick="window.open(this.href,'_blank','height=500,width=500,status=no, toolbar=no,menubar=no,location=no');return false"
    >Link TEXT or IMAGE HERE</a>
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    You don't need a label inside the onclick. The onclick already identifies that it is JavaScript.
    True.

    Quote Originally Posted by felgall View Post
    There are also a couple of other changes you can make that will make the onclick code more portable so that you don't need to change it if you have multiple links that you want to use it with.
    Portable???

  6. #6
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Portable meaning you can use the same code for different situations, although it's bad enough that the code referred to is embedded inline. By replacing the explicit url with this.href he can just copy this on other elements and not retype the same link over and over.

  7. #7
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SoulScratch View Post
    Portable meaning you can use the same code for different situations, although it's bad enough that the code referred to is embedded inline. By replacing the explicit url with this.href he can just copy this on other elements and not retype the same link over and over.
    Portable means cross-broser.

    However.

    I never thought of the this.href solution. Have to test how it is handled by the different browsers. If they all accept it, this is GREAT.

  8. #8
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by REMIYA View Post
    Portable means cross-broser.

    However.

    I never thought of the this.href solution. Have to test how it is handled by the different browsers. If they all accept it, this is GREAT.

    View Post
    There are also a couple of other changes you can make that will make the onclick code more portable so that you don't need to change it if you have multiple links that you want to use it with.
    He clearly mentions what he means by portable (which I bolded and underlined for you). What he has suggested does not make any difference cross-browser wise, and all modern user agents would support the legacy DOM property href on the current HTMLElement.

  9. #9
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SoulScratch View Post
    all modern user agents
    All modern? What about older, not everybody surfs with the last browser?
    For example IE 8 is on the way, and ppl still surf with IE 5.5.

  10. #10
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by REMIYA View Post
    All modern? What about older, not everybody surfs with the last browser?
    For example IE 8 is on the way, and ppl still surf with IE 5.5.
    It does support this.href, since its a legacy dom property as mentioned. Are you not able to grab a copy and test out for yourself?

  11. #11
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SoulScratch View Post
    It does support this.href, since its a legacy dom property as mentioned. Are you not able to grab a copy and test out for yourself?
    This is what I mentioned in a first place. If tests show it works, then it is good.

    Actually you are just speaking for the sake of it, not reading the posts on the first place.

  12. #12
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by REMIYA View Post
    This is what I mentioned in a first place. If tests show it works, then it is good.

    Actually you are just speaking for the sake of it, not reading the posts on the first place.
    You shouldn't need to test 'this.href' on browsers, as 95%+ of them support this, since these are LEGACY DOM 0 PROPERTIES which have been supported for YEARS and YEARS.

  13. #13
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SoulScratch View Post
    You shouldn't need to test 'this.href' on browsers, as 95%+ of them support this, since these are LEGACY DOM 0 PROPERTIES which have been supported for YEARS and YEARS.
    I think this is off topic. Thank you so far for your replies.

  14. #14
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's not off topic, as it relates to Javascript implementations on user agents which have access to DOM properties that enable them to manipulate documents in various ways. As I said in the other thread, please pickup a basic JS book and learn before making useless/false statements.

  15. #15
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SoulScratch View Post
    It's not off topic, as it relates to Javascript implementations on user agents which have access to DOM properties that enable them to manipulate documents in various ways. As I said in the other thread, please pickup a basic JS book and learn before making useless/false statements.
    Thank you once again.

  16. #16
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,713
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    this.href predates the DOM and is supported on all javascript capable browsers, having been available since the beginnings of javascript.

    Check out the JavaScript 1.0 Authoring Guide and look in the Statements section.

    Try the following out on a Netscape 2.0 browser.

    Code html4strict:
    <a href="somelink.html" onclick="alert(this.href)">Test</a>

    The above won't work on Netscape 1.0 and the original Mosaic browser, only because javascript wasn't invented yet.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Tags for this Thread

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
  •