Nov 21 / dominicscaife

Flash and SEO Javascript tips

A few useful snippets of Javascript that are useful in understanding how a flash based website that reads xml files for content works.

Okay this is for two different reasons.

“&” or “;” are the common seperator between search queries to a url, as in a url will normally be set up:

http://www..com/.html?=&=&…. etc.

This is why I put the functionality in the original search to only look at far as the next “&” in the search. You can change this though, just change the “var matches = ” line to the following:

var matches = window.location.search.match(‘(\\?|^)(.*)$’);

Now it will simply use the whole search query as the url, like you originally specified:

http:///.html?http://www.asite.co.uk/?dgh=dfgadf&afgda=adfad

The above should now work.

The has problem is for a different reason. When you put a URL into a browser it splits it up as follows:

protocol//host[:port]/path?search#hash

These different parts of the URL can be accessed by:

window.location.protocol

window.location.host

window.location.port

window.location.path.. etc.

So, the “search” part, which is what we’re searching, will only go up the first “#” that is encounters, everything after that will be the “hash” part.

To get around this, I suppose you could just add the hash, if it exists, onto the end of the url. To do this, change the:

window.location.href = matches[2]},5000)

into

window.location.href = matches[2]},5000) + window.location.hash

So your whole code would be:

I’ve tested this in both Firefox and IE 7 :) .

Leave a Comment