Jump to content

On URL Change


The Little Guy

Recommended Posts

There are ways of doing it, but it requires I little bit of work. I assume this is so you can have Ajax functionality while still being able to bookmark.

 

The way I have done it in the paste is to use a simple MVC pattern. You need a controller function which is called on every click, this then checks the url and executes a function accordingly.

Link to comment
Share on other sites

Yeah your pretty much right :)

 

Right now, I have a function called loadBody(). this loads the body, and changes the url (like posted above). After I posted this, and did some more research, the only conclusion I could come to was to set an interval.

 

The main reason I want this is so I can have a "history", because if I press the back button nothing would happen. But when I added the following code, it works, but I am not sure how hard that is on the browser, especially if it is run for say an hour.

var interval = setInterval('watchWindow()', 200);
function watchWindow(){
var wlocation = window.location.hash.toString();
if(wlocation != clocation){
	var loca = window.location.toString();
	var qstring = loca.match(/#(.+)/);
	if(qstring != null)
		var qstrings = qstring[1].split('&');
	if(qstring != null){
		for(var i=0; i<qstrings.length;i++){
			tmp = qstrings[i].split('=');
			if(tmp[0]=='v')
				v = tmp[1];
			else{
				ext = tmp[0];
				val = tmp[1];
			}
		}
	}
	clocation = wlocation;
	loadBody(v, ext, val);
}
}

 

Does that all make sense?

Link to comment
Share on other sites

What I have seems to work fine... I have left the site running for 8+ hours, and there seems to be no cache build up or anything slowing down my computer or browser. But... I have only tried that with Chrome, so that doesn't mean a different browser wouldn't start to slow down the computer and/or browser.

 

Any thoughts?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.