Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loading pages in a frameset

Status
Not open for further replies.

werD420

Technical User
Sep 14, 2004
181
US
Hello,

Ive got a knowledge base app with a frameset which consists of a table of contents and content frame. I run an action onload of the frame to keep track of the current frame location via reading the src attribute of the frame if i cant check it via javascript. For the most part i accomplish this by loading the external pages via a javascript function like so
Code:
//function to open new pages either in a new window or in the content frame  
    function openpage(address, isclient, nuwindow) {
    var mf;
    if(address != '') {
    mf = document.getElementById("mainFrame");
    mf.setAttribute("src", address);   
    //mainFrame.location.reload(true);
    
    }
    }


now the problem im having is this.. if i load an external page for instance google in the content frame(mf) and the user then chooses to go to google images or a site via google search but then clicks the google button from my page(only an example) the page will not change because the attribute remains the same. im not trying to run code from there site or anything like that id just like to get the user back to where they need to go(an external company site). basically is there a way to refresh the site thats in a frameset via the frame page. The only thing i can think of is to create a local page that redirects based on querystring that way i dont have to deal with this broken model (in my case).


thaks for any thoughts or advice

DrewG

MCP, .Net Solutions Development <%_%>
 
You might be able to trap the onreadystate event of the frame. This fires every time the frame contents change.

I've mocked up some code:

Code:
	function openPage(address, isclient, nuwindow) {
	   var mf;
	   if(address != '') {
	     loading = true;
         currentAddress = address;
	     mf = document.getElementById("mainFrame");
         mf.setAttribute("src", address);   
	}

	function handleReadyStateChange() {
		if (event.srcElement.readyState == 'complete') {
			if (loading) 
				loading = false;
			else
				currentAddress = '';
		}
	}

You'll need to add
Code:
onreadystatechange='handleReadyStateChange()'
to your frame tag.

I haven't tested this but it might do what you want. Also, I've no idea if this is IE specific.

Chaz
 
Thanks for your response

Ive tried your code with a bit of manipulation but i alsways seem to get Object doesnt support this property or method line 1 char 1.

Code:
 var loading = false;
    function openPage(address, isclient, nuwindow) {
       var mf;
       if(address != '') {
         loading = true;
         currentAddress = address;
         mf = document.getElementById("mainFrame");
         mf.setAttribute("src", address);   
        }
    }
    function handleReadyStateChange() {
        if (event.srcElement.readyState == 'complete') {
            if (loading){ 
                loading = false;
            }else{
                currentAddress = '';
        }
    }
    }


Is this the only way or is there something im not doing right here?


MCP, .Net Solutions Development <%_%>
 
any thoughts on another way to do this? Im at a loss here, but i really need this basic functionality

MCP, .Net Solutions Development <%_%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top