[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

JavaScript not working in firefox

Posted on 2007-10-15
12
Medium Priority
?
2,824 Views
Last Modified: 2013-12-07
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...
0
Comment
Question by:sajjadnaveed
  • 4
  • 4
  • 3
  • +1
12 Comments
 
LVL 23

Expert Comment

by:basicinstinct
ID: 20076979
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
 

Author Comment

by:sajjadnaveed
ID: 20077015
I have tried this one , but still problem persists.. same error
0
 
LVL 23

Expert Comment

by:basicinstinct
ID: 20077039
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:sajjadnaveed
ID: 20077141
still same.. no use
0
 
LVL 23

Expert Comment

by:basicinstinct
ID: 20077163
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
 

Author Comment

by:sajjadnaveed
ID: 20077247
i remoed this... also but still with firefox the problem is same.. IE is treating javascript ok but firefox is issuing same error
0
 
LVL 35

Expert Comment

by:TimYates
ID: 20077765
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
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 375 total points
ID: 20078070
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
 
LVL 23

Expert Comment

by:basicinstinct
ID: 20081546
ahhhh, closing </iframe> tag...
well well well, thanks mplungjan...
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20184764
why a "B" grade?
0
 

Author Comment

by:sajjadnaveed
ID: 20184822
becose solution worked partially... :P
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20184893
So if you had posted that information (along with what still does not work) we could perhaps help you more?
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question