INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: HTML Coding  (Read 3099 times)

KingSparta

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 20048
HTML Coding
« 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?
Logged
Retired Military, Airborne, Air Assault, And Flight Wings.
Model Trains, Internet, Ham Radio
https://MyAAGrapevines.com
Fayetteville, NC, USA

imugli

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1601
Re: HTML Coding
« Reply #1 on: May 16, 2016, 05:36:37 pm »

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. 





 

KingSparta

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 20048
Re: HTML Coding
« Reply #2 on: May 16, 2016, 07:23:19 pm »

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

Quote
<!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>
Logged
Retired Military, Airborne, Air Assault, And Flight Wings.
Model Trains, Internet, Ham Radio
https://MyAAGrapevines.com
Fayetteville, NC, USA

KingSparta

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 20048
Re: HTML Coding
« Reply #3 on: May 16, 2016, 08:22:41 pm »

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');">
Logged
Retired Military, Airborne, Air Assault, And Flight Wings.
Model Trains, Internet, Ham Radio
https://MyAAGrapevines.com
Fayetteville, NC, USA

imugli

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1601
Re: HTML Coding
« Reply #4 on: May 16, 2016, 09:54:33 pm »

If that works  ;D

KingSparta

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 20048
Re: HTML Coding
« Reply #5 on: May 17, 2016, 08:23:16 pm »

yep, I found the code, after looking for two days for something that worked.

thanks
Logged
Retired Military, Airborne, Air Assault, And Flight Wings.
Model Trains, Internet, Ham Radio
https://MyAAGrapevines.com
Fayetteville, NC, USA

imugli

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1601
Re: HTML Coding
« Reply #6 on: May 18, 2016, 04:44:35 am »

Always the way. Glad you found it.
Pages: [1]   Go Up