|
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?
irt.org | Knowledge Base | JavaScript | Link | Q1686 [ previous next ]
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?
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>
|
|
|
Copyright © 1996-2009 irt.org, All Rights Reserved.