Javascript onclick doesn't work in IE
Hi,
I have been searching on google to find the answer for my question, but I have not succeeded to find the answer for my question, that's why I m trying to find my answer in here. I have a dynamic page with 10 anchors and 10 div element in it. Each anchor is named like anchor_1, anchor_2, ... and each div is called div_1, div_2, ... . I have created an oclick event handler for each anchor to change the content of the corresponding div element. For example, if you press on a_23, div_23 contents should be changed. PHP Code:
I have bunch of onclick event handlers and since they worked on FF I thought everything is alright. Fortunately or Unfortunately I don't have IE on my computer to test everything immediately, so almost non of my javascript simple functions work in IE. Any idea how to solve this problem? |
http://www.thescripts.com/forum/thread460633.html
... lots of reasons an onclick won't work. Best to provide a concrete example. http://www.thescripts.com/forum/thread632970.html |
href='javascript:vote_link(this)' if within an anchor tag?
maybe useful but dont know... |
Thanks, but that didn't help me. I'm trying to use YUI library. They have several useful functions that can help me to some level. Because all data are inside a tab, not everything works fine, when the tab content are changed as I wanted. That's why I tried to use inline event handlers. In YUI they have a function that can return an array of element based on their class or tag name which is pretty interesting. However their tabview function event handler seem to be interesting, but for some reason I can't get them working fine with my specific application.
|
I just noticed that I had done exact same thing previously and it is working fine with Internet Explorer.I have something like this in my page:
PHP Code:
PHP Code:
PHP Code:
|
No access to XP @ the moment to test this.
I was looking @ the parsing for doctype and javascript. Controlling the DOCTYPE and XML Declaration http://www.xml.com/lpt/a/1027 XML CDATA http://www.w3schools.com/xml/xml_cdata.asp Code:
<script> http://www.contentwithstyle.co.uk/Blog/98/ Code:
<xsl:text disable-output-escaping="yes"> |
Alright, after playing around with my code I just realized that it has nothing to do with the document type. I just created an anchor element in a new empty xhtml file and called the function and it worked in FF and Opera. I guess it should be working in IE, too. I don't have IE to test with right now. The other day when I checked IE and Opera, I realized that they have the same behavior to this event.
Then I did exact same thing with my site but it didn't work in it. After that instead of calling an external function I wrote something like this: PHP Code:
Anyone had the same problem before? |
Javascript is a hell to debug and developing in Opera and trying to get it to work in IE can double your development times.
I see that in your first example you don't have a semicolon (;) after the function call statement. Not sure whether it is required, but IE can be picky. Next, surround your function call with "Alert()" calls so you know what piece of code is executed. IE skips the entire onclick block if there is just one error in the JS. Installing a VM is almost a necessity to test you HTML in IE. jlinkels |
Thank you. But I realized that when working with xslt, you cannot write a javascript file in an empty file. You have to include your external javascript file inside an xsl file so that you can call functions inside your external javascript. But unfortunately, if you are working with a javascript library like YUI, you cannot use them unless you place all of them in xsl files which doesn't seem to be the best way. I have not figured it out yet how to eliminate that problem.
As you said it's a good practice to include return false; after calling a function. |
Thank you. But I realized that when working with xslt, you cannot write a javascript file in an empty file. You have to include your external javascript file inside an xsl file so that you can call functions inside your external javascript. But unfortunately, if you are working with a javascript library like YUI, you cannot use them unless you place all of them in xsl files which doesn't seem to be the best way. I have not figured it out yet how to eliminate that problem.
As you said it's a good practice to include return false; after calling a function. |
All times are GMT -5. The time now is 12:29 PM. |