Works in Firefox, but not in IE

C

CalgaryWebGuy

Please help,

My class assignment is due today and I am all finished except for one
small portion.

The instructor wants us to import a script from somewhere else, and for
some reason I deceided to make it more complicated than it needs to be.

What I am trying to do is create a popup when the user leaves the page
( I know pop-ups are bad, but they are a part of the course) that
displays the imported script. It works perfectly in firefox, but IE
displays everything except the script.

I am a total loss at why, hopefully someone can shed some light on this
for me:

(the closeWin() is called from the body tag using
onUnload="closeWin()")

// Import a script from somewhere else.
function closeWin() {
closeWindow = window.open("","closeWin",
"toolbar=no,resizable=no,width=500,height=225,scrollbar=no,left=250,top=200")
closeWindow.document.write("<html><head><title>An Imported
Script<\/title><\/head><body><table align='center'><tr><td colspan='2'
align='center'><p>The following is an imported script<\/p><script
src='external.js' language='JavaScript'
type='text/javascript'>importedScript()<\/script><p
align='center'><font face='arial' size='-2'>This free script provided
by<\/font><br><font face='arial, helvetica' size='-2'><a
href='http://javascriptkit.com'>JavaScript
Kit</a><\/font><\/p><\/td><\/tr><\/table><\/body><\/html>")
}

function importedScript() {
//Roller Coaster Script - By JavaScriptKit Over 200+ free scripts
here!

var fs=1
var direction="right"
function rollertext(whichone){
var thetext=whichone
for (i=0;i<thetext.length;i++){
document.write(thetext.charAt(i).fontsize(fs))

if (fs<7&&direction=="right")
fs++
else if (fs==7){
direction="left"
fs--
}
else if (fs==1){
direction="right"
fs++
}
else if (fs>1&&direction=="left")
fs--

}
}
//Change below text to your won
rollertext("Life is like a roller coaster ride. Hang on tight!")
}
 
R

Robert Iver

I have a very rudimentary knowledge of JavaScript (I'm more of a Java
guy myself), but where you had written:

<script src='external.js' language='JavaScript'
type='text/javascript'>

The file "external.js", is that where the imported script should be
stored? Rather than along with this code?

Also, and this might be due to formatting reasons when you posted this
code, but the comment that shows up immediately after the
importedScript() function is a single line comment, but it looks like
it's split along two lines....leaving "here!" on a line by itself,
which could be causing the code to break.

I'm sure you'll get some people smarter than me to repsond to this, but
I just wanted to throw my two cents in.
 
C

CalgaryWebGuy

Thanks for the response,

The imported script is stored in the .js file, and so is the script
that is writing the page 'on the fly' so, it is refrencing itself in a
round about way. But as far as I am aware, this should work, as when it
calls the script, it's a new page entirely that is created by the
closeWin() function. If that makes any sense.

The formating issue is due to how this message is posted, and is coded
properly.
 
W

web.dev

CalgaryWebGuy said:
<script src='external.js' language='JavaScript'
type='text/javascript'>importedScript()<\/script>

In the line above, you are importing a script and attempting to execute
statements. That is incorrect. Referencing an external script and
execution of statements within the script tags should be kept separate
like so:

<script src = "external.js" type = "text/javascript"></script>
<script type = "text/javascript">
importedScript();
</script>

Format the above solution into your assignment.
Don't assume FF is the absolute browser of choice for javascript. In
this case, IE was doing it correctly.
 
R

Randy Webb

CalgaryWebGuy said the following on 6/14/2006 10:22 AM:
Please help,

My class assignment is due today and I am all finished except for one
small portion.

The instructor wants us to import a script from somewhere else, and for
some reason I deceided to make it more complicated than it needs to be.

What I am trying to do is create a popup when the user leaves the page
( I know pop-ups are bad, but they are a part of the course) that
displays the imported script. It works perfectly in firefox, but IE
displays everything except the script.

I am a total loss at why, hopefully someone can shed some light on this
for me:

(the closeWin() is called from the body tag using
onUnload="closeWin()")

// Import a script from somewhere else.
function closeWin() {
closeWindow = window.open("","closeWin",
"toolbar=no,resizable=no,width=500,height=225,scrollbar=no,left=250,top=200")
closeWindow.document.write("<html><head><title>An Imported
Script<\/title><\/head><body><table align='center'><tr><td colspan='2'
align='center'><p>The following is an imported script<\/p><script
src='external.js' language='JavaScript'
type='text/javascript'>importedScript()<\/script>

If Firefox is executing that importedScript() call then FF is the one
that is dead wrong here.

This is what you script tag looks like (formatted)

<script src='external.js' type='text/javascript'> importedScript()
<\/script>

The function call should never be executed if it has a src attribute.

To "fix" it, add a second script block that makes the call:

<script src='external.js' type='text/javascript'></script>
<script type='text/javascript'> importedScript()</script>
 
C

CalgaryWebGuy

That's the fix!!

Thanks Randy & Web.Dev!!

Randy said:
CalgaryWebGuy said the following on 6/14/2006 10:22 AM:

If Firefox is executing that importedScript() call then FF is the one
that is dead wrong here.

This is what you script tag looks like (formatted)

<script src='external.js' type='text/javascript'> importedScript()
<\/script>

The function call should never be executed if it has a src attribute.

To "fix" it, add a second script block that makes the call:

<script src='external.js' type='text/javascript'></script>
<script type='text/javascript'> importedScript()</script>
 
C

CalgaryWebGuy

I agree I probably shouldn't use FF as a default browser when editing..
I just have such a prejudice against Microsoft that I automatically use
FF instead. Old habits are hard to break!

Thanks again!
 
R

Randy Webb

CalgaryWebGuy said the following on 6/14/2006 2:11 PM:
I agree I probably shouldn't use FF as a default browser when editing..

Nobody said that. What was said was not to believe that FF is always
right - it isn't.
I just have such a prejudice against Microsoft that I automatically use
FF instead. Old habits are hard to break!

Is top posting such an old habit that you can't break it?

Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
 
C

CalgaryWebGuy

Randy said:
CalgaryWebGuy said the following on 6/14/2006 2:11 PM:

Nobody said that. What was said was not to believe that FF is always
right - it isn't.

My point was that the majority of internet users still use IE, so
testing should probably be done in IE, and then checked in the other
browsers for compatability. I never indicacted that I believe that FF
is always right, it's simply not a microsoft product, which gives it a
huge bonus in my books.
Is top posting such an old habit that you can't break it?

Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?

Sorry for the offensive top posting. I know people have different
posting prefrences, and it does cause the conversation to break apart.
But emailing is generally always done using top posting, so to answer
your question, yes it is a hard habit to break. Especially for those of
us who only sparesly participate in newsgroupts.

Google Groups is smart enough to hide the quoted text, but I guess I
just wasn't thinking about the fact that people use different readers.

Now if I were to answer emails at work, in the fashion that I just
responded to this message, I know I would get the response "Why did you
send me back my email without answering?"

So, either one of two things need to happen,

1) Everyone adopt the top posting method, as whether people like it or
not, it is the norm in emails and likely will be in newsgroups down the
road.

2) Educate everyone who uses a computer to post properly.

Which do you think is more likely to be succesfull?

Another question, why do newsgroup posts nearly always end up as off
topic arguments?
 
R

Randy Webb

CalgaryWebGuy said the following on 6/14/2006 7:31 PM:
My point was that the majority of internet users still use IE,

True. Sad but true.
so testing should probably be done in IE, and then checked in the other
browsers for compatability.

I typically do it the other way around but you have a point.
I never indicacted that I believe that FF is always right, it's simply
not a microsoft product, which gives it a huge bonus in my books.


Sorry for the offensive top posting. I know people have different
posting prefrences, and it does cause the conversation to break apart.
But emailing is generally always done using top posting, so to answer
your question, yes it is a hard habit to break. Especially for those of
us who only sparesly participate in newsgroupts.

I very seldom see top-posted emails. The only time they get "reversed"
is when they are forwarded. But that may just be me said:
Google Groups is smart enough to hide the quoted text, but I guess I
just wasn't thinking about the fact that people use different readers.

Its more about a convention in this group than different readers. There
are some groups that prefer top posting, some prefer bottom posting.
Still others prefer inter-leaved posting (as this one and yours was).
Now if I were to answer emails at work, in the fashion that I just
responded to this message, I know I would get the response "Why did you
send me back my email without answering?"

My first thought about that was "This is Usenet, not email" but then
after thinking about it, it falls into the same category as top-posting
at all. It depends on the convention used. And in my own experience, I
do not see a lot of top-posted emails.
So, either one of two things need to happen,

1) Everyone adopt the top posting method, as whether people like it or
not, it is the norm in emails and likely will be in newsgroups down the
road.

That I disagree with. It is up to each group to adopt a convention and
this group has adopted inter-leaved posting as the preferred method of
posting.
2) Educate everyone who uses a computer to post properly.

Ummm, ok :)
Which do you think is more likely to be succesfull?

Probably neither :)
Another question, why do newsgroup posts nearly always end up as off
topic arguments?

Such is the nature of Usenet I suppose. But it is not an "argument", per
se, to me as much as it is a conversation about the posting conventions
used in this group.
 
C

CalgaryWebGuy

Randy Webb wrote:

Such is the nature of Usenet I suppose. But it is not an "argument", per
se, to me as much as it is a conversation about the posting conventions
used in this group.

True, which is why I only sparsely participate in groups. A great idea,
ruined by morons.

Have a good one!
 
L

Lasse Reichstein Nielsen

CalgaryWebGuy said:
My point was that the majority of internet users still use IE, so
testing should probably be done in IE, and then checked in the other
browsers for compatability.

On the other hand, IE is so forgiving that you can create utter crap
and still have it look reasonably in IE. It then becomes hard work,
bordering on complete rewrite, to make it work in other browsers.

Starting in Firefox and writing standards compliant code, while
watching for warnings and errors, the page that you end up with will
work in almost all other browsers. It's often a relatively small fix
to make it work in IE too, and you have IE's conditional comments to
help you add IE specific CSS.

I would prefer to start in a non-IE browser (personally I use Opera as
my main browser, so that's where I usually start).


Sorry for the offensive top posting. I know people have different
posting prefrences, and it does cause the conversation to break apart.
But emailing is generally always done using top posting, so to answer
your question, yes it is a hard habit to break.

It annoys the *beep* out of me in emails too, but I can see the
advantage when a new person is introduced in an ongoing mail
correspondance ... keeping the entire history in the mail.

For news, where previous messages are available to everybody, at
least for a while, you don't need (and don't want) to keep the
entire history in each message.
1) Everyone adopt the top posting method, as whether people like it or
not, it is the norm in emails and likely will be in newsgroups down the
road.

When they pry my newsgroup reader from my cold dead hands!
2) Educate everyone who uses a computer to post properly.

Which do you think is more likely to be succesfull?

Neither. So both live on, and this group goes for the second.

/L
 
K

Kevin Scholl

CalgaryWebGuy said:
My point was that the majority of internet users still use IE,
True.

so testing should probably be done in IE,
Absolutely.

and then checked in the other browsers for compatability.

The best course of action is to DEVELOP to the recommended standard(s),
which will cover most of the pool of "popular" browsers, including (for
the most part) IE. Then TEST in a variety of browsers. Because the
standards are least supported by IE, one might then possibly need to
apply a few workarounds for that one browser. But with Microsoft's
acceptance of conditional comments this is most easily done with IE, as
opposed to trying to apply hacks for the several browsers which are
actually doing things right in the first place.

By developing for IE first, you cut out a sizable chuck of potential
visitors and/or create a sizable amount of extra work. By doing as
outlined above, you cover far more bases with minimal extraneous effort
(many times, none at all).

--

*** Remove the DELETE from my address to reply ***

======================================================
Kevin Scholl http://www.ksscholl.com/
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top