Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Don't use <script /> ever - IE bug.
Old 01-30-2007, 08:52 PM Don't use <script /> ever - IE bug.
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
Trades: 0
After a lot of frantic remote desktop hops, I figured out why my page was showing up on FireFox, but not IE 6 or 7. It was a pretty frustrating struggle, trying to turn one of my best visitor-grabbing pages back on.

One lesson is that I shouldn't use FF for most of my browsing. But everyone already knows that. The more novel lesson is don't make your script tags self closing; always use an open tag and a close tag if you want anything below them on the page to show up.

I've got enough java functionality on a big page that it made sense to put this into an external js file. I thought I'd be clever and save a few bytes, so I tried this:

Code:
<script src="ImageSwap.js" />
at the top of the page. When I navigated to the page in IE, I would get the nav bar and page header, but no content. Worse yet, I've made a lot of changes since the last time I looked at the page using IE, and spent a lot of time looking for a div set to display:none, or something like that.

Code:
<script src="ImageSwap.js"></script>
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
 
Register now for full access!
Old 01-30-2007, 09:22 PM Re: Don't use <script /> ever - IE bug.
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
On the same topic (<sarcasm>don't ya just love IE</sarcasm>).
If you write canonical JSP's (strict XML format) then this:
Code:
 <script src="ImageSwap.js"></script>
will get converted to this
Code:
 <script src="ImageSwap.js" />
by the JSP compiler. So, its required to put something in the tag to prevent the collapse
Code:
 <script src="ImageSwap.js">/* image swap */</script>
I know you are trying to save every byte but, if you want pages that pass XHTML validation, be sure to add the type attibute.
willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 01-31-2007, 03:22 PM Re: Don't use <script /> ever - IE bug.
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
Quote:
One lesson is that I shouldn't use FF for most of my browsing.
Nope, I have to disagree. IE is the LEAST compliant with CSS and if you're using IT to weigh how your page is going to look in FF, Safari, or Opera, you're going to have nothing but problems !

IN XHTML EVERY tag must be closed. If a tag doesn't normally have a end tag, like the <script></script> tag DOES, then and only then would you use the / -- as you do for an <img> tag: <img src="blahblah" alt="blah" />

Your error was in not using the PROPER end tag for the <script>.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 01-31-2007, 04:08 PM Re: Don't use <script /> ever - IE bug.
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
For once, I have to disagree with you ladynred.

Closing an xhtml tag with <tag /> is prefectly correct in all case.
But as you pointed out, the problem lies in IE.

The fact it that ie will read this notation correctly only if he is not in "quircks mode", which is fairly hard to be with his "@#§§" standard compliance.

In my firm, we are using the tandem XML (generated by oracle pl/sql)+XSL to generate web pages, and this is an well known problem, and the reason for so much exception rules for ie that we don't even count them anymore...
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 02-03-2007, 10:35 AM Re: Don't use <script /> ever - IE bug.
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
Quote:
Originally Posted by ForrestCroce View Post
One lesson is that I shouldn't use FF for most of my browsing. But everyone already knows that.
Actually, everyone disagrees with that statement. The usage of Firefox globally is around 30% but, for more technical users its much higher. On my website around 70% of visitors use Firefox. Also, the majority of Mac and Linux users use FF.
The lesson is that you should test your pages more (with a variety of browsers)
FF/IE/Opera at the minimum. You should also try for Safari/Konqueror if possible.
Something also recommended by many, is to develop in strict XHTML and send the correct mime-type (application/xhtml+xml) for it (yes it breaks IE, but FF is smarter) in your dev/test environments. This will cause the page to break for the smallest of html errors, allowing you to catch them early. Then use the text/html mime-type on public servers to allow the browser to be more lenient.
willcode4beer is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Don't use <script /> ever - IE bug.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.43790 seconds with 12 queries