homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Problem with Opera and external Javascript sheet

 7:06 pm on Jan 17, 2003 (gmt 0)

Is there a problem with using external Javascript scripts in Opera?

I use the following code to link from an XHTML 1.0. page to an external script:-

<meta http-equiv="Content-Script-Type" content="text/javascript" />
<script src="../scripts-lib/script.js" language="JavaScript" type="text/javascript"></script>

On the same page I call a function:-

<a href="javascript:myfunction()">blahblah</a>

All standard stuff and wirks fine in IE6 and NN6. But Opera 6.05 always returns an error alert.

name: ReferenceError
message: Reference to undefined variable: No such variable 'myfunction'

If I put the script in the page head, then it finds the function OK.

I have tried calling the function by onClick but that doesn't work either.

Is there anything I have to do for external scripts to work in Opera?

Thanks in advance.



 10:26 pm on Jan 17, 2003 (gmt 0)

This is a very curious problem. Have you tried using an absolute path to the .js file?


 12:11 am on Jan 18, 2003 (gmt 0)

Hi tedster,

Yes, I tried it just now. But it made no difference.


 5:28 am on Jan 18, 2003 (gmt 0)

Hmmm... I just searched the Opera knowledge base and Google and found nothing about a bug. Let's get down to basics.

HTML and CSS validates


 1:15 pm on Jan 18, 2003 (gmt 0)

Hi tedster,

Opera Version 6.05
Build 1140
Platform Win32
System Windows 2000
validated XHTML 1.0 transitional and CSS2

Actually the link is on the site in my profile. Top left labelled "Swap bar". It would be interesting to see if anybody else has the same problem, or if it's something to do with my Opera installation.



 4:37 pm on Jan 18, 2003 (gmt 0)

Opera is very picky when it comes to tag locations. Is the <script> tag located within the <head></head> section?

I'm using external scripts all the time, and they work .. So it must be something else. Not that it should matter in XHTML 1.0, as long as you're not using Strict, but have you tried omitting language="Javascript" .. You know it's not necessary?


 4:41 pm on Jan 18, 2003 (gmt 0)

Just looked at the source of your site ..
Tried moving the script tag down?
I don't see why it wouldn't work .. :(


 5:34 pm on Jan 18, 2003 (gmt 0)

Problem solved. It's appears to be a bug.

If the name of the js file includes the word "script" Opera does not load the file. If I change the name, then Opera loads the file.

Presumably Opera gets confused if another word "script" appears between the <script> tag and </script>. It doesn't mind "scripts" or "scriptanything", but fails on the exact match.

The js file url was "domain/scripts-js/lib-script.js". It is now "domain/scripts-js/lib-standard.js", and Opera loads it.

Of course I still have a second problem, because now Opera is objecting to "innerHTML", but at least its no longer giving those misleading messages. :)

Many thanks for all your help.



 5:46 pm on Jan 18, 2003 (gmt 0)

You might find this link useful then:


 5:52 pm on Jan 18, 2003 (gmt 0)

You might find this link useful then:

Thanks DrDoc but I've already been there. "innerHTML" is not supported by Opera. There's a thread about it here which suggests using the DOM method, but doesn't actually provide any example code. So I'll have to do some digging.


 6:04 pm on Jan 18, 2003 (gmt 0)

Opera 7 will support it though :)


 6:13 pm on Jan 18, 2003 (gmt 0)

Yes! Dare I say about time?

I'm afraid the only opera I like comes with singing. :)

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved