You need to be logged in to post in the forums. If you do not have an account, please sign up first.
Script works IE but not Opera. Why?
I was wondering if any body could tell me what have I done wrong that this script only works with Internet Explorer browser but not the latest Opera browser.Thanks in advance...
<script LANGUAGE="JavaScript1.2" type="text/javascript1.2">
//this example only seems to work in the Internet Explorer browser.
where = prompt("Where do you want to go today? Netscape, Microsoft, Yahoo or other?");
switch (where) {
case "Netscape" :
window.location="http://www.netscape.com/";
break;
case "Microsoft" :
window.location="http://www.microsoft.com/";
break;
case "Yahoo" :
window.location="http://www.yahoo.com/";
break;
default :
window.location="http://www.mobilestimulus.com/";
}
</script>
If it's not working at all, then there's something really wrong...
When I tested, it worked fine... however I also didn't use any specific JS versions, just:
You could do something like:
When I tested, it worked fine... however I also didn't use any specific JS versions, just:
But you have to remember that it's case sensitive, so if you type in "microsoft" it won't find a match, you have to type in "Microsoft".<script type="text/javascript">
</script>
You could do something like:
That way if the user types in "microsoft", "Microsoft", "MICROSOFT" etc... it doesn't matter.var where = prompt("Where do you want to go today? Netscape, Microsoft, Yahoo or other?").toLowerCase();
switch (where) {
case "netscape":
...
MY PC ●MY BUTTONS [TR] ●[EXT] ●QUICK EDIT ●ICON LIST ●[EXT] ●RSS FEED ● FORUM:POSTING RULES ●RULES OF CONDUCT
Thankyou. When I changed it to:
It started working. But that doesn't answer why
doesn't display the prompt at all.
<script LANGUAGE="JavaScript" type="text/javascript">
It started working. But that doesn't answer why
<script LANGUAGE="JavaScript1.2" type="text/javascript1.2">
doesn't display the prompt at all.
Presumably because one or more of the following:
1. I don't think the "type" attribute accepts a version, it's always just "javascript"
2. JavaScript 1.2 support may have been dropped
(it's 13 years old, so Opera might just avoid it, other browsers probably just ignore the 1.2)
3. Something else in the document (DocType, etc) doesn't allow for it.
4 Unknown...lol
Check the Error Console in Opera (Tools - Advanced - Error Console) it should say something about it.
1. I don't think the "type" attribute accepts a version, it's always just "javascript"
2. JavaScript 1.2 support may have been dropped
(it's 13 years old, so Opera might just avoid it, other browsers probably just ignore the 1.2)
3. Something else in the document (DocType, etc) doesn't allow for it.
4 Unknown...lol
Check the Error Console in Opera (Tools - Advanced - Error Console) it should say something about it.
MY PC ●MY BUTTONS [TR] ●[EXT] ●QUICK EDIT ●ICON LIST ●[EXT] ●RSS FEED ● FORUM:POSTING RULES ●RULES OF CONDUCT
This script doesn't seem to work as well.
<html>
<head>
<title>Descriptive Links</title>
<script LANGUAGE="JavaScript" type="text/javascript">
function describe(text) {
window.status = text;
return true;
}
function clearstatus() {
window.status="";
}
</script>
</head>
<body>
<h1>Descriptive Links</h1>
<p>Move the mouse pointer over one of
these links to view a description:</p>
<ul>
<li><a HREF="order.html"
onMouseOver="describe('Order a product'); return true"
onMouseOut="clearstatus()">
Order Form</a>
</li>
<li><a HREF="email.html"
onMouseOver="describe('Send us a message'); return true"
onMouseOut="clearstatus()">
Email</a>
</li>
<li><A HREF="complain.html"
onMouseOver="describe('Insult us, our products, or our families'); return true"
onMouseOut="clearstatus()">
Complaint Department</a>
</li>
</ul>
</body>
</html>
Because the normal status message (for the links) overrides the manual one... if you add the describe() to the LI's it works except when you mouse-over the links, this isn't an Opera issue... all browser *should* behave like that (and they all do except IE), if you want to have a description for a link use the "title" attribute, like:
< a href="order.html" title="Order a product">Order Form</a >
Which will show a tooltip with the message.
If you want to avoid that you would probably have to use another element type, like a span, then have the "onclick()" event go to the URL (window.location = url), or you can do something really ugly like have a JavaScript loop and try and force the message to be there...but don't do that.
< a href="order.html" title="Order a product">Order Form</a >
Which will show a tooltip with the message.
If you want to avoid that you would probably have to use another element type, like a span, then have the "onclick()" event go to the URL (window.location = url), or you can do something really ugly like have a JavaScript loop and try and force the message to be there...but don't do that.
MY PC ●MY BUTTONS [TR] ●[EXT] ●QUICK EDIT ●ICON LIST ●[EXT] ●RSS FEED ● FORUM:POSTING RULES ●RULES OF CONDUCT
Originally posted by mobilestimulus:
<script LANGUAGE="JavaScript1.2" type="text/javascript1.2">
I think IE is parsing that despite the TYPE value, not because. Also see this test I wrote a while ago
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>Quick and Very Dirty Javascript Version Test</title>
</head>
<body>
<script type="application/javascript">
function dirty(type) {document.write(type+'
');}
</script>
<script language="javascript1.5">dirty("lang-1.5");</script>
<script language="javascript1.6">dirty("lang-1.6");</script>
<script language="javascript1.7">dirty("lang-1.7");</script>
<script language="javascript1.8">dirty("lang-1.8");</script>
<script language="javascript1.8.1">dirty("lang-1.8.1");</script>
<script language="javascript1.9">dirty("lang-1.9");</script>
<script language="javascript2.0">dirty("lang-2.0");</script>
<script type="application/javascript;version=1.5">dirty("1.5");</script>
<script type="application/javascript;version=1.6">dirty("1.6");</script>
<script type="application/javascript;version=1.7">dirty("1.7");</script>
<script type="application/javascript;version=1.8">dirty("1.8");</script>
<script type="application/javascript;version=1.8.1">dirty("1.8.1");</script>
<script type="application/javascript;version=1.9">dirty("1.9");</script>
<script type="application/javascript;version=2.0">dirty("2.0");</script>
</body>
</html>
The DnD Sanctuary — a safety net for My Opera's demise.