...

View Full Version : variable not defined first time around



gilgalbiblewhee
10-26-2010, 01:02 PM
When I select an article from this link for the first time (since the page is loaded) it shows error. But the second select/click shows the div popup:
http://www.gbgrafix.com/thewheelofgod/twotexts/articles/

The error points out that the file is not defined even though I defined it inline.

I'm going to try and paste that part of the js code in the popup div and see if it works. If there's a better solution let me know thanks.

abduraooft
10-26-2010, 01:15 PM
When I select an article from this link for the first time (since the page is loaded) it shows error. But the second select/click shows the div popup: Please provide the steps to reproduce the error.

gilgalbiblewhee
10-26-2010, 01:46 PM
Please provide the steps to reproduce the error.


function openArticle(){
var req = createRequest();
if(req){
req.onreadystatechange = function(){
if(req.readyState){
if(req.readyState == 4){
if(req.status == 200){
var newDiv = document.createElement("div");
newDiv.setAttribute('id', 'for_articles');
newDiv.innerHTML = req.responseText;
// And then inject it:
document.body.appendChild(newDiv);
//document.write(newDiv.innerHTML);
}
}
}
}
//document.write(file+thisurlext+getKeyURL);
req.open("GET", file, true);
req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
req.send(null);
}

}
in the separate js file will bring the div popup. If I paste it after the code:


...
<a href="JavaScript: var file='article_popup.php?article=john-psalm43.php';" onclick="openArticle();" style="display: block; color: #7A1010; font-weight: bold; font-family: Verdana, Geneva, sans-serif; font-size: 12px; width: 245px; height: 10px; padding: 0px 0px 5px 5px;" onmouseover="this.style.backgroundColor='#7A1010'; this.style.color='#ffffff';" onmouseout="this.style.backgroundColor='#ffffff'; this.style.color='#7A1010';">
...
<script language="javascript">
function openArticle(){
var req = createRequest();
if(req){
req.onreadystatechange = function(){
if(req.readyState){
if(req.readyState == 4){
if(req.status == 200){
var newDiv = document.createElement("div");
newDiv.setAttribute('id', 'for_articles');
newDiv.innerHTML = req.responseText;
// And then inject it:
document.body.appendChild(newDiv);
//document.write(newDiv.innerHTML);
}
}
}
}
//document.write(file+thisurlext+getKeyURL);
req.open("GET", file, true);
req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
req.send(null);
}
}
</script>
Then:

Error: openArticle is not defined
Source File: /articles/
Line: 1
openArticle is the function.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum