Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New Coder
    Join Date
    May 2003
    Location
    UK
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Example javascript for Opera please!!!

    Does anybody know of a site that provides working examples / code for javascript to make it work with Opera.

    I am struggling to get all my javascript to work on Opera as it is all IE6 focused.

    Should I just forget other browsers and focus soley on IE6? Who uses anything else except for developers.
    They only tell you its a stupid question when they don't know the answer!

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    620
    Thanks
    1
    Thanked 20 Times in 20 Posts
    Opera does JavaScript quite well. What are you having problems with?

  • #3
    New Coder
    Join Date
    May 2003
    Location
    UK
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well firstly I can't get...

    window.history.forward();

    to work.

    I understand that unlike all other browsers Opera takes the cache seriously and won't let me prevent it caching the pages! At least that is what I was told. But I can't get a workaround.

    But my main point was, I come from an IE6 background and it seems to let me do javascript in a fairly relaxed way. When I try it out on Opera it always needs some fixing before it will work.

    What I guess would be ideal is a site that shows how to achieve in opera the same result as you get from IE6.

    In the old days everything was aimed at cross browser compatability with IE4 and Netscape (RIP), but now I guess Opera is the new competitor. So how to make things cross browser compatible for Opera and IE6??

    You may say that I should learn to code javascript correctly - but as most of us learn from existing code (which works in IE6) - can you see it's a catch 22.
    They only tell you its a stupid question when they don't know the answer!

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    620
    Thanks
    1
    Thanked 20 Times in 20 Posts
    Forward:  The "window.history.forward();" command works in Opera 6.05; what version are you using?

    Caching:  Check out the "Samples of my work > Guaranteed Fresh" page at:

      http://spruce.flint.umich.edu/~jalarie/

    Catch 22:  Yes, copy code for learning purposes; no, don't use bad code on your pages.  Get a good book or web reference and learn to do it correctly.  I like:

      http://developer.netscape.com/docs/m...uide/index.htm

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Opera 7 is the latest - if you're working with 6 then it's no surprise you're having difficulties - 7 was the first to have proper DOM support.

    But window control is not part of the DOM ... and anything that involves manipulating the history is likely to be problematic - Opera is a lot more user-centric than IE, and it disallows a lot of things that would work in IE, for usability and security reasons. I don't know if this is one of those, but it might be.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    620
    Thanks
    1
    Thanked 20 Times in 20 Posts
    Opera 7.21 also does "window.history.forward();" correctly.

  • #7
    New Coder
    Join Date
    May 2003
    Location
    UK
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is the code as it is on the page...


    <script language='JavaScript'>
    <!--
    window.history.forward();
    //-->
    </script>

    ... I am using ....

    Version 7.02
    Build 2668
    Platform Win32
    System Windows XP
    _
    Java Java not installed

    Can you please point out wher I am going wrong!
    They only tell you its a stupid question when they don't know the answer!

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    620
    Thanks
    1
    Thanked 20 Times in 20 Posts
    <script language='JavaScript'>
    <!--
    window.history.forward();
    //-->
    </script>
    This is not a function nor a link, it gets executed in-line as the page is loading.&nbsp; At that moment, there is no forward page to go to.&nbsp; Once you load another page and go back to this page, you could set off a link or function to go forward, and that should work properly.

  • #9
    New Coder
    Join Date
    May 2003
    Location
    UK
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's the point.

    In IE6 when i load this page it does nothing (great), but when i go back to this page using the back button, it wont go back!

    In opera the same page loads and does nothing (great too), but when i go back to it using the back button it shows the cached page.
    They only tell you its a stupid question when they don't know the answer!

  • #10
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    620
    Thanks
    1
    Thanked 20 Times in 20 Posts
    Maybe you want "window.location.replace('target.com');" instead.

  • #11
    New Coder
    Join Date
    May 2003
    Location
    UK
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts
    tried that too.

    It seems the problem is a fundemental one where opera says that the cashe is a "photo" of what you saw earlier, whereas IE6 is happy to be played with by the programmer so that the cache is not what it seems.

    If opera insists on caching strictly then the page it shows when you click the back button is not dynamic. things like onload() etc don't happen when you looked at cached files.

    I tried using PHP server side to tell opera not to cache the page - this would force it to get the page from the web again and then all would work. But opera seems to ignore this too.

    I think i must accept that opera's cache is not to be messed with. Resistance is futile!
    They only tell you its a stupid question when they don't know the answer!

  • #12
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    620
    Thanks
    1
    Thanked 20 Times in 20 Posts
    When you go "back," you should be going back to what was there not loading something new.&nbsp;

    The example that I gave above (guaranteed fresh) will actually force a reload if you go back after more than 60 seconds.&nbsp; Change the timer if you want something less.

  • #13
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's quite right - when you go back in Opera it doesn't reload the page, it shows you literally what you were just looking at as a snapshot. This is the correct way, and also better in practise, since it means that going back uses almost no browser resources, compared to having to reload the page.

    But are there are practical disadvantages - some functions aren't executed; the window.onload event doesn't fire again.

    It's been debated heavily on the O7 mailing list, and I doubt very much whether this behavior will change. As it is, it's a happy state of affairs most of the time except that the occassional bit of javascript breaks. But to change it could mean that all pages are slower, all the time. You can see how it's not such a bad trade off in those terms
    Last edited by brothercake; 10-15-2003 at 06:00 PM.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •