SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unespected behavior in Firefox

    Hi people.

    Now I'm study the way to send values from forms to Javascript functions in the same page. To do that, I did make a very simple page who send the values from a list and print the value in the same page:

    -----------------------------
    <select name="Region" onchange="showtheValue(this.value)" >
    <option selected value="">Select</option>
    <option value="One">One</option>
    <option value="Two">Two</option>
    <option value="Three">Three</option>
    <option value="Four">Four</option>
    </select>

    <script type="text/javascript" language="JavaScript">
    function showtheValue(cual) {
    if (cual != undefined) {
    document.write(cual);
    }
    }
    </script>

    ------------------------------

    The script works fine in Explorer, but in Firefox the tab allwas show loading, like a infinite loop, but the execution of the Script has finished.




    I dont know if it's a Firefox bug or a Programming error.

    PLase, help me.

  2. #2
    SitePoint Zealot logitron's Avatar
    Join Date
    Feb 2006
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey!

    I know what you are referring to. It happens when you have an intrinsic event handler (i.e. "onChange") that calls "document.write". Instead of modifying the current document, it creates a new one. To quote a W3 source that I found: "Note that 'document.write' or equivalent statements in intrinsic event handlers create and write to a new document rather than modifying the current one."
    I hope that helps.
    Patrick Smith
    PHP Programmer

  3. #3
    SitePoint Addict Mirek Komárek's Avatar
    Join Date
    Dec 2006
    Location
    Prague
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try to simply use document.close() http://msdn.microsoft.com/workshop/a...hods/write.asp


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
  •