INTERACT FORUM
More => Music, Movies, Politics, and Other Cheap Thrills => Topic started by: KingSparta on May 16, 2016, 12:51:16 pm
-
I don't know the answer to this but someone here may since there are so many smart people around here.
I have a page index.html that redirects to index0.html to index9.html
I would like a way to change or mask the url
so instead of: MyAAGrapevines.com/index5.html
it will show up like: MyAAGrapevine.com/index.html
any Ideas?
-
By redirect do you mean a 301 redirect, or that you have links to the other pages on index.html?
If it's the latter, the easiest way is via jquery and ajax, so that the page doesn't actually reload or go to the index5.html page, but simply loads the content of your index5.html into the body of your index.html page.
I'll run up a JSFiddle for you a little later to demonstrate what I mean.
-
index.html picks a random page index0.html to index9.html
when the lets say index5.html loads it shows it to the user.
but "MyAAGrapevine.com/index5.html" is left in the url window of the browser (address bar), and I would prefer "MyAAGrapevine.com/index.html"
index.html code below
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var howMany = 9; // max number of items listed below
var page = new Array(howMany+1);
page[0]="index0.html";
page[1]="index1.html";
page[2]="index2.html";
page[3]="index3.html";
page[4]="index4.html";
page[5]="index5.html";
page[6]="index6.html";
page[7]="index7.html";
page[8]="index8.html";
page[9]="index9.html";
function rndnumber(){
var randscript = -1;
while (randscript < 0 || randscript > howMany || isNaN(randscript)){
randscript = parseInt(Math.random()*(howMany+1));
}
return randscript;
}
quo = rndnumber();
quox = page[quo];
window.location=(quox);
// End -->
</SCRIPT>
</HEAD>
-
this is what I figured out
<script type="text/javascript">
function ChangeUrl(title, url) {
if (typeof (history.pushState) != "undefined") {
var obj = { Title: title, Url: url };
history.pushState(obj, obj.Title, obj.Url);
} else {
alert("Browser does not support HTML5.");
}
}
</script>
<body onload="ChangeUrl('index.html', 'index.html');">
-
If that works ;D
-
yep, I found the code, after looking for two days for something that worked.
thanks
-
Always the way. Glad you found it.