Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1686 How can I generate a page in JavaScript when a button is pressed that both replaces the current page in the browser's history, and cannot be linked to directly?

You are here: irt.org | FAQ | JavaScript | Link | Q1686 [ previous next ]

Try the following which allows pages to be defined in JavaScript, and then loaded when a button is pressed:

<html>

<head>

<script language="JavaScript"><!--
function page1() {
  return '<html><body>Hello world (1)</body></html>';
}

function page2() {
  return '<html><body>Hello world (2)</body></html>';
}

function nextpage(page) {
  if (!document.image) {
    location.replace('javascript:page' + page + '()');
  }
  else {
    location.href = 'javascript:page' + page + '()';
  }
}
//--></script>

</head>

<body>

<form>
<input type="button" value="Next page 1" onClick="nextpage(1)">
<input type="button" value="Next page 2" onClick="nextpage(2)">
</form>

</body>

</html>

©2018 Martin Webb