Saturday 4 June 2011

How Do I Change URL Appearance (HTML, Javascript)?

Well,


I would like to change the appearance of a URL in the URL bar,


so that %26quot;http://www.mysite.com/search/index.php?鈥?


appears as %26quot;http://www.mysite.com/search%26quot;


i have seen it done on the old version of runescape but their coding doesn%26#039;t seem to work on my page,


Cheers Oliver





This is the head section of the section of runescape which appears as just runescape.com.





%26lt;head%26gt;


%26lt;script language=%26quot;javascript%26quot;%26gt;


try {


if (self!=top) {


if(self.location.href.indexOf(%26quot;/de/%26quot;)!=-鈥?|| self.location.href==%26quot;http://www.runescap鈥?top.location.href=%26quot;http://www.runescape.鈥?br>

else top.location.href=%26quot;http://www.runescape.鈥?br>

}


}


catch(er) {alert(er);}


%26lt;/script%26gt;


%26lt;title%26gt;RuneScape - the massive online adventure game by Jagex


Ltd%26lt;/title%26gt;


%26lt;meta name=%26quot;Description%26quot;


content=%26quot;RuneScape is a massive 3d multiplayer adventure, with monsters to kill, quests to complete, and treasure to win. You control your own character who will improve and become more powerful the more you play.%26quot;%26gt;


%26lt;meta name=%26quot;Keywords%26quot;


content=%26quot;Runescape, Jagex, free, games, online, multiplayer, magic, spells, java, MMORPG, MPORPG, gaming%26quot;%26gt;


%26lt;link rel=%26quot;shortcut icon%26quot;


href=%26quot;http://runescape.com/favicon.ico%26quot; type=%26quot;image/x-icon%26quot;%26gt;


%26lt;/head%26gt;


|||First three answers are spam links.





If you want to show a different URL in the address bar, you%26#039;re talking about using a so-called %26quot;url-rewrite%26quot; - which will not work without either:





1. Frames





or





2. Server side scripting





First method is the easiest, but also the most looked down upon, as using frames for the sake of using frames (or an address bar issue) is considered amateur work... but if you have no other option:





Make a page called index.html (or default.html, depends on your host); use the Frameset DOCType, and load a single frame to the page you actually want to show.





The JavaScript checks which address is showing in the top bar (should be the main frame container page; an added side effect is that if someone loads your page inside one of *their* frames, your page breaks out of it and reloads itself in its own frameset.

No comments:

Post a Comment