SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    It's Warmer in the Basement xxJoyfulxx's Avatar
    Join Date
    Jul 2004
    Location
    Elmhurst, IL
    Posts
    169
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onClick function not working in IE7

    I've been searching the archives for an answer to this problem but I'm unable to find what I'm looking for.

    I'm using a textarea box and the onClick function to automatically highlight the code inside of it for the user to copy & paste elsewhere. But this function is not working at all in IE7. (tested fine in Chrome, FF & IE8) I googled and I see that this is a common error in IE7 but I can't seem to figure out what to replace the onClick code with to make it do the same thing.

    I'm on a very beginner level when it comes to Javascript, so if someone could take a look at this code and help me out with a solution for IE7 I would really appreciate it.

    HTML Code:
    <textarea name="code" cols="16" rows="3" wrap="VIRTUAL" class="bginput" onClick="this.focus();this.select()">
    &lt;style type="text/css"&gt;
    CSS code here
    &lt;/style&gt;
    </textarea>
    Thank you,
    Joy

  2. #2
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't reproduce the problem, maybe its caused by another event handler on the page.
    You can lose this.focus() since clicking on the box focuses it anyway.
    Tab-indentation is a crime against humanity.

  3. #3
    It's Warmer in the Basement xxJoyfulxx's Avatar
    Join Date
    Jul 2004
    Location
    Elmhurst, IL
    Posts
    169
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's the only single event handler on the page - it's the only piece of javascript even on the page. And it still does not work in IE7.

    Here is a test page for you guys with the example. Works fine in IE8, FF and Chrome. Unfortunately I would love it to work for the IE7 crowd also.

    http://joyful1.com/test.html

    Any other ideas? (I took off the this.focus() - thank you for the tip!)

    Joy

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,607
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    It works fine in IE7.
    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
    It's Warmer in the Basement xxJoyfulxx's Avatar
    Join Date
    Jul 2004
    Location
    Elmhurst, IL
    Posts
    169
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, thanks for the reply. I've tried it on 2 different machines (my desktop and laptop) and gotten the same result.

    I will assume this issue is resolved - if anyone tests and comes across it NOT working, I'd appreciate a reply. Thank you!

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    You may need to walk us through.

    For example, the computer os (xp sp3, vista sp1) and browser version (8.6001.18702 in IE7 compatibility mode) where you place the mouse, what you click on, how many times with which button, etcetera
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #7
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yah worked just fine in IE7 on xp sp3


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
  •