| | #1 |
| Brian Kindsvater War Room Member Join Date: 2004 Location: Sparta
Posts: 4,084
Thanks: 153
Thanked 4,818 Times in 1,585 Posts
Blog Entries: 190 |
I am replacing html links on an auto generated site with JavaScript links on the fly and writing the JavaScript the links to an external file. So my web pages have a JavaScript onclick function that is using the link in the external file. Sometimes when the pages are loaded the links work fine. Sometimes they do not. Nothing happens. But after refreshing the page, and thus writing to the external file twice - then they work. Similarly, if I fopen the external file using the 'w' command to reset it, and then write the links to it, the web page links do not work. But if I refresh the web page then they work again. Any ideas? --- Using Internet Explorer when the link does not work I get this error code: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0) Timestamp: Thu, 6 Oct 2011 04:06:34 UTC Message: Object expected Line: 190 Char: 1 Code: 0 URI: http://[my web page] Refresh the page, and the error goes away and the link works fine. . . |
| |
| | #2 |
| VIP Warrior War Room Member Join Date: 2006 Location: , , USA.
Posts: 1,795
Thanks: 70
Thanked 287 Times in 259 Posts
|
Have you checked the code at line 190? Something may be loading out of order. Have you tried in FF? Where is the site? |
| |
| | #3 |
| HyperActive Warrior War Room Member Join Date: 2011
Posts: 129
Thanks: 2
Thanked 13 Times in 12 Posts
|
If you are using external javascript libraries like jquery, have you tried loading them first before you loaded your scripts which make use of the library?
|
| | |
| |
| | #4 |
| Active Warrior Join Date: 2010
Posts: 75
Thanks: 8
Thanked 8 Times in 7 Posts
|
It's hard to tell from the brief description, but if you haven't already, be sure to load your javascript after the dom loads. Most framewoks will have an onDomReady function for this purpose. You can also set it up without using a framework by executing your code in the right place. If you are getting errors it could be your script is breaking before everything loads since code is trying to access something that doesn't exist. Here is a link to jquery that explains it a bit. |
| |
|
| Bookmarks |
| Tags |
| javascript, page, refresh, work |
| |