Javascript loads in Firefox but not Chrome or IE?
So my code is working perfectly in Firefox but my external pop.js file
won't load in Chrome or IE. The javascript console is giving me the error
"Uncaught ReferenceError: popup is not defined mywebsite.com/:26 onload"
However I'm a bit lost and can't really see what I should change.
Hopefully someone can help me solve what should be a relatively easy
problem.
External pop.js code:
function toggle(div_id) {
var el = document.getElementById(div_id);
if ( el.style.display == 'none' ) { el.style.display = 'block';}
else {el.style.display = 'none';}
}
function popup(windowname) {
toggle('blanket');
toggle(windowname);
} window.onload = function() {
setTimeout(function() {
document.getElementById('popUpDiv').style.display = 'block';
}, 2000);
}
Javascript in Header:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>1328 Matches Found!</title>
<link href="css/style1.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/pop.js"></script>
<script type="text/javascript">
function sorry() {
document.getElementById('q3').style.display='none';
document.getElementById('q4').style.display='inline';
setTimeout("document.getElementById('q4').style.display='none';document.getElementById('q5').style.display='inline';",3000);
setTimeout("document.getElementById('q5').style.display='none';document.getElementById('q6').style.display='inline';",5500);
setTimeout("document.getElementById('q6').style.display='none';document.getElementById('q7').style.display='inline';",8000);
setTimeout("document.getElementById('q7').style.display='none';document.getElementById('q8').style.display='inline';",10500);
setTimeout("window.location='http://externallink.com/file.php';",12500);
}
</script>
<script language="JavaScript"
src="http://j.maxmind.com/app/geoip.js"></script>
</head>
Javascript in body:
<body onload="popup('popUpDiv')">
<div id="container">
<div id="mainContent">
<div id="blanket" style="display:none;"></div>
<div id="popUpDiv" style="display:none;">
<div class="popup-content">
<div class="headline">1328 Matches Found in <script
language="JavaScript">document.write(geoip_city());</script>!</div>
<div class="date">
<script type="text/javascript">
<!--
// Array of day names
var dayNames = new
Array("Sunday","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday");
// Array of month Names
var monthNames = new Array(
"January","February","March","April","May","June","July",
"August","September","October","November","December");
var now = new Date();
document.write(dayNames[now.getDay()] + ", " +
monthNames[now.getMonth()] + " " +
now.getDate() + ", " + now.getFullYear());
// -->
</script>
</div>
<div class="pre-sell-text">
Vivamus sagittis lacus vel augue laoreet rutrum
faucibus dolor auctor. Donec ullamcorper nulla non
metus auctor fringilla. Morbi leo risus, porta ac
consectetur ac, vestibulum at eros. Maecenas sed diam
eget risus varius blandit sit amet non magna. Lorem
ipsum dolor sit amet, consectetur adipiscing elit.
Praesent commodo cursus magna, vel scelerisque nisl
consectetur et.
</div>
<div class="footer">
<div class="ad"><img src="images/boot01.jpg"
width="110" height="225" alt="" /></div>
<div class="questionnaire">
<table width="450" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td width="299"><div id="q1" name="q1"
onclick="document.getElementById('q1').style.display='none';document.getElementById('q2').style.display='inline';"
style="vertical-align: text-top;">
<center>
Question 1 of 3:
<h1><p>Cras justo odio, dapibus ac facilisis in, egestas
eget quam.</p></h1>
<br />
<span style="font-size: 24px;"><a href="#">
<div id="yesdiv"
onclick="document.getElementById('q1').style.display='none';document.getElementById('q2').style.display='inline';">Yes
<input
onclick="document.getElementById('q1').style.display='none';document.getElementById('q2').style.display='inline';"
type="radio" />
</div>
</a> <a href="#">
<div id="yesdiv"
onclick="document.getElementById('q1').style.display='none';document.getElementById('q2').style.display='inline';">No
<input
onclick="document.getElementById('q1').style.display='none';document.getElementById('q2').style.display='inline';"
type="radio" />
</div>
</a></span>
</center>
</div>
<div id="q2" name="q2"
onclick="document.getElementById('q2').style.display='none';document.getElementById('q3').style.display='inline';"
style="vertical-align: text-top;">
<center>
Question 2 of 3:
<h1><p>Cras justo odio, dapibus ac facilisis in, egestas
eget quam.</p></h1>
<br />
<span style="font-size: 24px; vertical-align:
text-top;"><a href="#">
<div id="yesdiv"
onclick="document.getElementById('q2').style.display='none';document.getElementById('q3').style.display='inline';">Female
<input
onclick="document.getElementById('q2').style.display='none';document.getElementById('q3').style.display='inline';"
type="radio" />
</div>
</a> <a href="#">
<div id="yesdiv">Male
<input
onclick="document.getElementById('q2').style.display='none';document.getElementById('q3').style.display='inline';"
type="radio" />
</div>
</a></span>
</center>
</div>
<div id="q3" name="q3" onclick="sorry();"
style="vertical-align: text-top;">
<center>
Question 3 of 3:
<h1><p>Cras justo odio, dapibus ac facilisis in, egestas
eget quam.</p></h1>
<br />
<span style="font-size: 24px; vertical-align:
text-top;"><a href="#">
<div id="yesdiv">Yes
<input onclick="sorry();" type="radio" />
</div>
</a> <a href="#">
<div id="yesdiv">No
<input onclick="sorry();" type="radio" />
</div>
</a></span>
</center>
</div>
<div id="q4" name="q4" style="vertical-align: text-top;">
<center>
<h1><p>Cras justo odio, dapibus ac facilisis in, egestas
eget quam.</p></h1>
<br />
<img src="images/loading4.gif" alt="4" />
</center>
</div>
<div id="q5" name="q5" style="vertical-align: text-top;">
<center>
<h1><p>Cras justo odio, dapibus ac facilisis in, egestas
eget quam.</p></h1>
<br />
<img src="images/loading4.gif" alt="3" /><br />
<br />
<span style="font-size: 18px;"><p>Cras justo odio,
dapibus ac facilisis in, egestas eget
quam.</p></span><img src="images/check.png" width="18"
height="18" alt="" />
</center>
</div>
<div id="q6" name="q6" style="vertical-align: text-top;">
<center>
<h1><p>Cras justo odio, dapibus ac facilisis in, egestas
eget quam.</p></h1>
<br />
<img src="images/loading4.gif" alt="2" /><br />
<br />
<span style="font-size: 18px;"><p>Cras justo odio,
dapibus ac facilisis in, egestas eget
quam.</p></span><img src="images/check.png" width="18"
height="18" alt="9" /><br />
<span style="font-size: 18px;">1328 Matches Found in
<script
language="JavaScript">document.write(geoip_city());</script>!</span><img
src="images/check.png" width="18" height="18" alt="8"
/><br />
</center>
</div>
<div id="q7" name="q7" style="vertical-align: text-top;">
<center>
<h1><p>Cras justo odio, dapibus ac facilisis in, egestas
eget quam.</p></h1>
<br />
<img src="images/loading4.gif" alt="1" /><br />
<br />
<span style="font-size: 18px;"><p>Cras justo odio,
dapibus ac facilisis in, egestas eget
quam.</p></span><img src="images/check.png" width="18"
height="18" alt="7" /><br />
<span style="font-size: 18px;"><p>Cras justo odio,
dapibus ac facilisis in, egestas eget
quam.</p></span><img src="images/check.png" width="18"
height="18" alt="6" /><br />
<span style="font-size: 18px;"><p>Cras justo odio,
dapibus ac facilisis in, egestas eget
quam.</p></span><img src="images/check.png" width="18"
height="18" alt="5" /><br />
</center>
</div>
<div id="q8" name="q8" style="vertical-align: text-top;">
<center>
<h1><p>Cras justo odio, dapibus ac facilisis in, egestas
eget quam.</p></h1>
<br />
<span style="font-size: 18px;"><p>Cras justo odio,
dapibus ac facilisis in, egestas eget
quam.</p></span><img src="images/check.png" width="18"
height="18" alt="4" /><br />
<span style="font-size: 18px;"><p>Cras justo odio,
dapibus ac facilisis in, egestas eget
quam.</p></span><img src="images/check.png" width="18"
height="18" alt="3" /><br />
<span style="font-size: 18px;"><p>Cras justo odio,
dapibus ac facilisis in, egestas eget
quam.</p></span><img src="images/check.png" width="18"
height="18" alt="2" /><br />
<span style="font-size: 18px;"><p>Cras justo odio,
dapibus ac facilisis in, egestas eget
quam.</p></span><img src="images/check.png" width="18"
height="18" alt="1" /><br />
</center>
</div></td>
</tr>
</table>
</div>
<div class="ad"><img src="images/boot02.jpg"
width="110" height="225" alt="" /></div>
</div>
</div>
</div>
</div>
</div>
Thanks for the help.
No comments:
Post a Comment