JavaScript not working in firefox

Hello Epxerts,

Right now I am facing one serious problem, I am using one java script to position  div according to screen resolution, its working fine in IE but in FireFox its not working, I checked in Error Console and its issuing following error

"Error: XML tag name mismatch (expected iframe)
Source File: http://192.168.0.201:8080/resolution.js
Line: 26, Column: 2
Source Code:


The javascrip code , which im using in .js file is as below

===========

// JavaScript Document
<script  language="javascript 1.2">
<!--
if (screen.width==1024||screen.height==768)
document.write("<iframe id='content' style='position:absolute; width:680px; height:700px; z-index:1; left: 228px; top: 300px;'>");

else if (screen.width==1152||screen.height==864)
document.write("<iframe id='content' style='position:absolute; width:680px; height:700px; z-index:1; left: 294px; top: 300px;'>");

else if (screen.width==1280||screen.height==720)
document.write("<iframe id='content' style='position:absolute; width:680px; height:700px; z-index:1; left: 356px; top: 300px;'>");

else if (screen.width==1280||screen.height==768)
document.write("<iframe id='content' style='position:absolute; width:680px; height:700px; z-index:1; left: 356px; top: 300px;'>");

else if (screen.width==1280||screen.height==960)
document.write("<iframe id='content' style='position:absolute; width:680px; height:700px; z-index:1; left: 356px; top: 300px;'>");

else if (screen.width==1280||screen.height==1024)
document.write("<iframe id='content' style='position:absolute; width:680px; height:700px; z-index:1; left: 356spx; top: 300px;'>");

//else
//window.location.replace("http://www.designcelebrity.com/index.aspx")

-->

</script>

Please can any one fix this problem...
sajjadnaveedAsked:
Who is Participating?
 
Michel PlungjanConnect With a Mentor IT ExpertCommented:
1. you are not closing the iframe tag. You MUST do that with an </iframe>
It is not valid to use />

Also try this if the script is inline:

<script type="text/javascript"><![CDATA[
// JavaScript Document
var leftPos = 356; // default
if (screen.width<=1024) leftPos = 228;
else if (screen.width<=1152) leftPos = 294;
else if (screen.width<=1280) leftPos = 356;

document.write("<iframe id='content' style='position:absolute; width:680px; height:700px; z-index:1; left: "+leftPos+"px; top: 300px;'></iframe>");
]]></script>


and if not, just

// JavaScript Document
var leftPos = 356; // default
if (screen.width<=1024) leftPos = 228;
else if (screen.width<=1152) leftPos = 294;
else if (screen.width<=1280) leftPos = 356;
document.write("<iframe id='content' style='position:absolute; width:680px; height:700px; z-index:1; left: "+leftPos+"px; top: 300px;'></iframe>");
0
 
basicinstinctCommented:
try closing your iframe tags:

document.write("<iframe id='content' style='position:absolute; width:680px; height:700px; z-index:1; left: 228px; top: 300px;'/>");

see, it ends with /> instead of just >
0
 
sajjadnaveedAuthor Commented:
I have tried this one , but still problem persists.. same error
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
basicinstinctCommented:
try either of these two options:

First option:

document.write("&lt;iframe id='content' style='position:absolute; width:680px; height:700px; z-index:1; left: 228px; top: 300px;'/&gt;");

Second option:

document.write("<ifra" + "me id='content' style='position:absolute; width:680px; height:700px; z-index:1; left: 228px; top: 300px;'/>");
0
 
sajjadnaveedAuthor Commented:
still same.. no use
0
 
basicinstinctCommented:
in your external .js file you should only have javascript, ie you shouldn't have this:

<script  language="javascript 1.2">
<!--

Nor this:


-->

</script>
0
 
sajjadnaveedAuthor Commented:
i remoed this... also but still with firefox the problem is same.. IE is treating javascript ok but firefox is issuing same error
0
 
TimYatesCommented:
Can you post the source of the JS (now you've removed the un-necessary stuff), at least up past the error by a few lines
And the error as it is now (with line number, etc)?

How are you calling the script?  In the head?  Or the body?
0
 
basicinstinctCommented:
ahhhh, closing </iframe> tag...
well well well, thanks mplungjan...
0
 
Michel PlungjanIT ExpertCommented:
why a "B" grade?
0
 
sajjadnaveedAuthor Commented:
becose solution worked partially... :P
0
 
Michel PlungjanIT ExpertCommented:
So if you had posted that information (along with what still does not work) we could perhaps help you more?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.