SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Jan 2008
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Changing/Adding Elements

    I'm running code examples that are DHTML Utopia, chapter 1. With I.E. I'm able to change element attributes, move elements, create new elements by running code in a JavaScript function. However with Mozilla Firefox browser, the changes will quickly flash but return to the orignal code (prior to calling the JavaScript function). Is this a browser setting issue?

  2. #2
    SitePoint Evangelist
    Join Date
    Jul 2007
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you post an example of the code you've used?

  3. #3
    SitePoint Member
    Join Date
    Jan 2008
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    code snippet

    function testEvent3() {

    // Create Element
    var cnn_link = document.createElement('a');
    // set property attribute
    cnn_link.href = 'http://www.cnn.com/';
    // Create Text node of element
    var cnn_link_txt = document.createTextNode('CNN');
    // append text node to element
    cnn_link.appendChild(cnn_link_txt);
    // insert element onto page
    codepara.appendChild(cnn_link);
    }

    ......

    <BUTTON name="tryThis3" id="tryThis3" onclick="testEvent3();">Create Elements</BUTTON>

  4. #4
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is codepara?

  5. #5
    SitePoint Member
    Join Date
    Jan 2008
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    found the problem...not sure why

    I figured out why the problem occurs. I have a form statement with a # for the url. It seems Firefox tries to do a Get whereas IE simply performs the unclick event.

    <form method=GET ACTION="#">

    ...
    ...
    <BUTTON name="tryThis3" id="tryThis3" onclick="testEvent3();">Create Elements</BUTTON>
    </form>

    My button is not a submit button, so I would have thought it would not perform a Get in either IE or Firefox. Is there a way to handle this for both browsers?

  6. #6
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to specify the type (this is the attribute name) of the button. Values are submit, reset or button.

  7. #7
    SitePoint Member
    Join Date
    Jan 2008
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    got it, thanks.


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
  •