SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 42
  1. #1
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Browser compatibilty for this js code please

    Hi all,

    As far as total browser compatibility and usability is concerned - is the js code in the website ok please ?

    http://www.010805.com/favorites

    Any help appreciated.

    Regards.

    Dez.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,048
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    js err msg

    Opera gives
    JavaScript - http://www.010805.com/favorites/
    Event thread: click
    Error:
    name: TypeError
    message: Statement on line 7: Could not convert undefined or null to object
    Backtrace:
    Line 7 of linked script http://www.010805.com/favorites/bookmark.js
    window.external.AddFavorite(this.href, this.title);
    At unknown location
    [statement source code not available]

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Only Internet Explorer allows access to add to favorites from a link. All other browsers require that the person press CTRL-D or CTRL-T depending on the browser.

    To get rid of the error in modern browsers you can change it to

    Code:
    if (window.external && window.external.AddFavorite)
       window.external.AddFavorite(this.href, this.title);
    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="^$">

  4. #4
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dez, I suggest you read this page.
    Quote Originally Posted by felgall View Post
    All other browsers require that the person press CTRL-D or CTRL-T depending on the browser.
    You mean Windows browsers. Konqueror uses CTRL + B and many Mac browsers use Command/Cmd + D.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  5. #5
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many, many thanks for these comments and links - they are all useful and appreciated.

    I'll do some more work on it and come back to you.

    One thing, the add to favs on that page *does* work with my FF - didn't it work with your FF ?

    Dez.

  6. #6
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, you script adds a bookmark in FF, but the bookmark opens in the sidebar instead of in a normal window/tab. Did you not read the page I linked to?
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  7. #7
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kravvitz View Post
    Yes, you script adds a bookmark in FF, but the bookmark opens in the sidebar instead of in a normal window/tab. Did you not read the page I linked to?
    Aha, now I see - I had read the article very fully and implemented the code, but hadn't then tried to open the bookmark to see what had happened with it - now I understand the references to sidebar and side windows ;-)

    Now that I understand the problem more fully, and have used the code from that link - could someone please help to get code right, as it still doesn't seem to work ?

    http://www.010805.com/favorites/

    It still seems to save it into the sidebar ?

    Any help very much appreciated.

    Dez.

  8. #8
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    Only Internet Explorer allows access to add to favorites from a link. All other browsers require that the person press CTRL-D or CTRL-T depending on the browser.

    To get rid of the error in modern browsers you can change it to

    Code:
    if (window.external && window.external.AddFavorite)
       window.external.AddFavorite(this.href, this.title);
    Many thanks Stephen - the inputs appreciated.

    Would using the code above solve the sidebar problem ?

    Dez.

  9. #9
    SitePoint Addict Mirek Komárek's Avatar
    Join Date
    Dec 2006
    Location
    Prague
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is not bad idea to add page to sidebar, but I can imagine it just with special page made just for this reason. For example left menu from here http://www.sitepoint.com/forums/ If you combine sources above with this http://home.arcor.de/xbo/sidebar-cross-browser/ and this http://www.howtocreate.co.uk/tutoria...ateSidebar.php you can develop sidebar for all most often browsers.

  10. #10
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks for the input Mirek - really looking to avoid the side windows.

    Dez.

  11. #11
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dez View Post
    Aha, now I see - I had read the article very fully and implemented the code, but hadn't then tried to open the bookmark to see what had happened with it - now I understand the references to sidebar and side windows ;-)

    Now that I understand the problem more fully, and have used the code from that link - could someone please help to get code right, as it still doesn't seem to work ?

    http://www.010805.com/favorites/

    It still seems to save it into the sidebar ?

    Any help very much appreciated.

    Dez.

    Anyone ?

    Dez.

  12. #12
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have violated the terms of use for that script. The comment block says that it must be included with the script. Why should we continue to help you, especially when it seems that you don't understand a lot of what you should have read?
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  13. #13
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the friendly reply Kravvitz - it's appreciated I wasn't sure where to include that code, but I've now put it into the kravvitz.js file - if that's wrong, just let me know

    I had read the article very fully and implemented the code, but hadn't then tried to open the bookmark to see what had happened with it - now I understand the references to sidebar and side windows ;-)

    Now that I understand the problem more fully, and have used the code from that link - could someone please help to get code right, as it still doesn't seem to work ?

    http://www.010805.com/favorites/

    It still seems to save it into the sidebar ?

    Any help very much appreciated.

    Dez.

  14. #14
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone ?

  15. #15
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    There is no cross browser solution for anything that involves using Javascript to update anything outside of the web page since with the exception of the functionality that IE contains that is intended for use on INTRAnets most browsers provide minimal access to anything not in the page itself. As this access (small as it is) is being progressively shown to sometimes be the cause of many of the security holes in the various browsers the newer browser versions are progressively moving toward providing no access whatever to anything outside of the web page or at least limiting it to reading info about the brower itself only.
    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="^$">

  16. #16
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dez View Post
    Now that I understand the problem more fully, and have used the code from that link - could someone please help to get code right, as it still doesn't seem to work ?
    You seem to have missed the significance of this paragraph:
    The script looks for an element with the ID attribute set to "addBookmarkContainer" and appends a new link (<a>) element as a child of it.
    I don't see that ID in your page.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  17. #17
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    Only Internet Explorer allows access to add to favorites from a link. All other browsers require that the person press CTRL-D or CTRL-T depending on the browser.

    To get rid of the error in modern browsers you can change it to

    Code:
    if (window.external && window.external.AddFavorite)
    That test has always errored in I.E., presumably because addFavorite is type unknown.

    Use: if(window.external && typeof window.external.AddFavorite != 'undefined')
    Tab-indentation is a crime against humanity.

  18. #18
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kravvitz View Post
    I don't see that ID in your page.
    Thanks to all who have posted helpful comments here - it's definitely helping me to understand more about this.

    Kravvitz - it may have missed your perception, but I am new to this and am trying to learn - I'm sure we've all been at that juncture at some stage ! Does that ID go in the following code please ?

    <body>
    <ul class="test">
    <li><a class="bookmark" href="http://www.010805.com/favorites/" title="caption">Favorites</a></li>
    </ul>
    </body>
    </html>

    Also, just to clarify - doing this exactly as you kindly suggest, would the add to favorites work both in FF and IE with just 2 clicks and without any use of side windows in FF ?

    Any help much appreciated.

    Dez.

  19. #19
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The unique ID should be applied to whichever element you want to be the parent of the link that the script creates.

    It depends how you define "2 clicks". In Firefox you click then link, then you read the alert box and click "OK", and then press the keys it told you to press. Currently, only IE/Win and Opera 7+ provide the functionality you want.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  20. #20
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague View Post
    Opera gives
    Hi Mittineague,

    Many thanks for the input on this - it is appreciated.

    I assume that the solution that is being worked on with Kravvitz, would have no errors at all ?

    Dez.

  21. #21
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kravvitz View Post
    The unique ID should be applied to whichever element you want to be the parent of the link that the script creates.

    It depends how you define "2 clicks". In Firefox you click then link, then you read the alert box and click "OK", and then press the keys it told you to press. Currently, only IE/Win and Opera 7+ provide the functionality you want.
    Many thanks Kravvitz - the help is appreciated.

    Can anyone mention precisely what part of the code below that I would need to change at all please ?

    <ul class="test">
    <li><a class="bookmark" href="http://www.010805.com/favorites/" title="caption">Favorites</a></li>
    </ul>

    Any help is always appreciated.

    Dez.

  22. #22
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,048
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    js errors

    The page that Kravvitz linked to doesn't throw any javascript errors in Opera. Neither does your current page at http://www.010805.com/favorites/

  23. #23
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks Mittineague - I was a bit confused on that - thanks for clearing it up for me

    Dez.

  24. #24
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why would it have errors?

    Code:
    <ul class="test">
    <li><a class="bookmark" href="http://www.010805.com/favorites/" title="caption">Favorites</a></li>
    <li id="addBookmarkContainer"></li>
    </ul>
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  25. #25
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Relax Kravvitz, no-one said there were errors

    Many, many thanks for the code, and for helping me to understand this whole thing ! The helps been appreciated.

    Do you know if it's totally compat with all browsers, incl ie7 please ?

    All the best.

    Dez.


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
  •