Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Posts
    735
    Thanks
    4
    Thanked 1 Time in 1 Post

    variable not defined first time around

    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/thewheelofgo...exts/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.
    Compare bible texts (and other tools):
    TheWheelofGod

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,866
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    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.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Mar 2005
    Posts
    735
    Thanks
    4
    Thanked 1 Time in 1 Post
    Quote Originally Posted by abduraooft View Post
    Please provide the steps to reproduce the error.
    Code:
    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:
    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.
    Compare bible texts (and other tools):
    TheWheelofGod


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •