How to open another HTML page using Javascript
I am working on a website and thought of reducing the number of pages by writing a bit of lines in javascript. I have a table on a page which leads you to 15 other pages. So I thought of opening one page that has all the info of the 15 pages combined and display the content depending on which link is click on the table. One of my table data is as under
<td><a style="color:black;" onClick="openCompiler()">C++ Compiler</a></td>
I am triggering an event call openCompiler() when the link is clicked.
function openCompiler()
window.open("mypage.html")
document.getElementById(compiler).style.display="block";
In the page I have a wrapper(called compiler) which has no display initially but when the link is clicked , it opens the page and displays the wrapper (called compiler).
My above efforts have failed and am looking for another way as:
1) The window.open() is not able to open an HTML file on my folder.
2 I am not sure if the document.getElementById(compiler).style.display="block"; is looking for the element called compiler in the current page.
What I am looking for:
1) A way to open another html page using javascript.
2) A way to set style of an element on the new page from the initial page(one with the table).
All help is appreciated :)
javascript html
|
show 2 more comments
I am working on a website and thought of reducing the number of pages by writing a bit of lines in javascript. I have a table on a page which leads you to 15 other pages. So I thought of opening one page that has all the info of the 15 pages combined and display the content depending on which link is click on the table. One of my table data is as under
<td><a style="color:black;" onClick="openCompiler()">C++ Compiler</a></td>
I am triggering an event call openCompiler() when the link is clicked.
function openCompiler()
window.open("mypage.html")
document.getElementById(compiler).style.display="block";
In the page I have a wrapper(called compiler) which has no display initially but when the link is clicked , it opens the page and displays the wrapper (called compiler).
My above efforts have failed and am looking for another way as:
1) The window.open() is not able to open an HTML file on my folder.
2 I am not sure if the document.getElementById(compiler).style.display="block"; is looking for the element called compiler in the current page.
What I am looking for:
1) A way to open another html page using javascript.
2) A way to set style of an element on the new page from the initial page(one with the table).
All help is appreciated :)
javascript html
Does the opened page have to be in a new tab/window?
– lucasem
Dec 28 '14 at 7:21
window.openreturn reference to new opened window
– Grundy
Dec 28 '14 at 7:22
1
ismypage.htmlan Object of the namemypageand the propertyhtmlholds the URL or are you just missing the quotes as it is already the namewindow.open("mypage.html");
– Axel Amthor
Dec 28 '14 at 7:22
@AxelAmthor was missing the quotes
– user4375224
Dec 28 '14 at 7:24
@lucasem nope it should not be
– user4375224
Dec 28 '14 at 7:24
|
show 2 more comments
I am working on a website and thought of reducing the number of pages by writing a bit of lines in javascript. I have a table on a page which leads you to 15 other pages. So I thought of opening one page that has all the info of the 15 pages combined and display the content depending on which link is click on the table. One of my table data is as under
<td><a style="color:black;" onClick="openCompiler()">C++ Compiler</a></td>
I am triggering an event call openCompiler() when the link is clicked.
function openCompiler()
window.open("mypage.html")
document.getElementById(compiler).style.display="block";
In the page I have a wrapper(called compiler) which has no display initially but when the link is clicked , it opens the page and displays the wrapper (called compiler).
My above efforts have failed and am looking for another way as:
1) The window.open() is not able to open an HTML file on my folder.
2 I am not sure if the document.getElementById(compiler).style.display="block"; is looking for the element called compiler in the current page.
What I am looking for:
1) A way to open another html page using javascript.
2) A way to set style of an element on the new page from the initial page(one with the table).
All help is appreciated :)
javascript html
I am working on a website and thought of reducing the number of pages by writing a bit of lines in javascript. I have a table on a page which leads you to 15 other pages. So I thought of opening one page that has all the info of the 15 pages combined and display the content depending on which link is click on the table. One of my table data is as under
<td><a style="color:black;" onClick="openCompiler()">C++ Compiler</a></td>
I am triggering an event call openCompiler() when the link is clicked.
function openCompiler()
window.open("mypage.html")
document.getElementById(compiler).style.display="block";
In the page I have a wrapper(called compiler) which has no display initially but when the link is clicked , it opens the page and displays the wrapper (called compiler).
My above efforts have failed and am looking for another way as:
1) The window.open() is not able to open an HTML file on my folder.
2 I am not sure if the document.getElementById(compiler).style.display="block"; is looking for the element called compiler in the current page.
What I am looking for:
1) A way to open another html page using javascript.
2) A way to set style of an element on the new page from the initial page(one with the table).
All help is appreciated :)
javascript html
javascript html
edited Dec 28 '14 at 7:23
asked Dec 28 '14 at 7:17
user4375224
Does the opened page have to be in a new tab/window?
– lucasem
Dec 28 '14 at 7:21
window.openreturn reference to new opened window
– Grundy
Dec 28 '14 at 7:22
1
ismypage.htmlan Object of the namemypageand the propertyhtmlholds the URL or are you just missing the quotes as it is already the namewindow.open("mypage.html");
– Axel Amthor
Dec 28 '14 at 7:22
@AxelAmthor was missing the quotes
– user4375224
Dec 28 '14 at 7:24
@lucasem nope it should not be
– user4375224
Dec 28 '14 at 7:24
|
show 2 more comments
Does the opened page have to be in a new tab/window?
– lucasem
Dec 28 '14 at 7:21
window.openreturn reference to new opened window
– Grundy
Dec 28 '14 at 7:22
1
ismypage.htmlan Object of the namemypageand the propertyhtmlholds the URL or are you just missing the quotes as it is already the namewindow.open("mypage.html");
– Axel Amthor
Dec 28 '14 at 7:22
@AxelAmthor was missing the quotes
– user4375224
Dec 28 '14 at 7:24
@lucasem nope it should not be
– user4375224
Dec 28 '14 at 7:24
Does the opened page have to be in a new tab/window?
– lucasem
Dec 28 '14 at 7:21
Does the opened page have to be in a new tab/window?
– lucasem
Dec 28 '14 at 7:21
window.open return reference to new opened window– Grundy
Dec 28 '14 at 7:22
window.open return reference to new opened window– Grundy
Dec 28 '14 at 7:22
1
1
is
mypage.html an Object of the name mypage and the property html holds the URL or are you just missing the quotes as it is already the name window.open("mypage.html");– Axel Amthor
Dec 28 '14 at 7:22
is
mypage.html an Object of the name mypage and the property html holds the URL or are you just missing the quotes as it is already the name window.open("mypage.html");– Axel Amthor
Dec 28 '14 at 7:22
@AxelAmthor was missing the quotes
– user4375224
Dec 28 '14 at 7:24
@AxelAmthor was missing the quotes
– user4375224
Dec 28 '14 at 7:24
@lucasem nope it should not be
– user4375224
Dec 28 '14 at 7:24
@lucasem nope it should not be
– user4375224
Dec 28 '14 at 7:24
|
show 2 more comments
3 Answers
3
active
oldest
votes
This can't work in the way you designed it. Per definition, the loading of the new document in the new window is asynchronous, see here https://developer.mozilla.org/en-US/docs/Web/API/Window.open
So, the setting of a style immediately after the "open" call must fail, since the document with the according element ("compiler") must not be loaded at that time and likely will not be.
What you actually can do is, load the doc and wait for the onready event, but only in the new window, and do all the settings over there. You may also craft the document from the source window like this:
newWindow = window.open("", "Compiler", "" );
doc = newWindow.document;
doc.open("text/html","replace");
doc.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">');
doc.writeln("<html>");
doc.writeln("<head>");
....
doc.writeln("</html>");
doc.close();
just as an idea to proceed.
So I have to redo the whole document to make it work the way i want it to?
– user4375224
Dec 28 '14 at 7:38
add a comment |
Abandoning window.open:
Create an iframe:
var compiler = document.createElement('iframe');
compiler.src = "mypage.html";
compiler.id = "compiler";
Put it where you want it to be:
document.getElementById("compilercontainer").appendChild(compiler);
Change it:
compiler = document.getElementById("compiler");
var comdoc = compiler.contentWindow.document;
var style = comdoc.createElement('style');
style.innerHTML = ".foo color:orange";
comdoc.head.appendChild(style);
This could probably be made neater with JQuery, but that isn't tagged (and I understand pure JS DOM manipulation better, personally)
ur first two lines are not working
– user4375224
Dec 28 '14 at 7:35
@Mohit.Bhasi works fine on Saf8 and Chrome39
– lucasem
Dec 28 '14 at 7:38
using chrome , removed the window.open , still not working
– user4375224
Dec 28 '14 at 7:41
Try"./mypage.html"and check for case ("MyPage.HTML") when this is a local file on a WIN system!
– Axel Amthor
Dec 28 '14 at 7:46
add a comment |
well there are some issues here :)
1) jump to a new page using window.location="mypage.html" (remember the double quotes, single do as well)
2) you seem to forget about double quoting: document.getElementById("compiler").style.display="block";
3) you cannot refer to the "compiler" element from your function because when you get there, you have already loaded the new page.
You can do something like this:
window.location="mypage.html?id=compiler"
And in your mypage.html:
<head>
<script>
function display()
var id = parseURL();
document.getElementById(id).style.display="block";
function parseURL()
refer to: https://stackoverflow.com/questions/831030/how-to-get-get-request-parameters-in-javascript
</script>
</head>
<body onload="display()">
....
the idea is to pass the id of the element to be displayed to the new page via GET parameter and then get it back from the URL in the new page.
Refer to How to get "GET" request parameters in JavaScript?
Mauro
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f27674425%2fhow-to-open-another-html-page-using-javascript%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
This can't work in the way you designed it. Per definition, the loading of the new document in the new window is asynchronous, see here https://developer.mozilla.org/en-US/docs/Web/API/Window.open
So, the setting of a style immediately after the "open" call must fail, since the document with the according element ("compiler") must not be loaded at that time and likely will not be.
What you actually can do is, load the doc and wait for the onready event, but only in the new window, and do all the settings over there. You may also craft the document from the source window like this:
newWindow = window.open("", "Compiler", "" );
doc = newWindow.document;
doc.open("text/html","replace");
doc.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">');
doc.writeln("<html>");
doc.writeln("<head>");
....
doc.writeln("</html>");
doc.close();
just as an idea to proceed.
So I have to redo the whole document to make it work the way i want it to?
– user4375224
Dec 28 '14 at 7:38
add a comment |
This can't work in the way you designed it. Per definition, the loading of the new document in the new window is asynchronous, see here https://developer.mozilla.org/en-US/docs/Web/API/Window.open
So, the setting of a style immediately after the "open" call must fail, since the document with the according element ("compiler") must not be loaded at that time and likely will not be.
What you actually can do is, load the doc and wait for the onready event, but only in the new window, and do all the settings over there. You may also craft the document from the source window like this:
newWindow = window.open("", "Compiler", "" );
doc = newWindow.document;
doc.open("text/html","replace");
doc.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">');
doc.writeln("<html>");
doc.writeln("<head>");
....
doc.writeln("</html>");
doc.close();
just as an idea to proceed.
So I have to redo the whole document to make it work the way i want it to?
– user4375224
Dec 28 '14 at 7:38
add a comment |
This can't work in the way you designed it. Per definition, the loading of the new document in the new window is asynchronous, see here https://developer.mozilla.org/en-US/docs/Web/API/Window.open
So, the setting of a style immediately after the "open" call must fail, since the document with the according element ("compiler") must not be loaded at that time and likely will not be.
What you actually can do is, load the doc and wait for the onready event, but only in the new window, and do all the settings over there. You may also craft the document from the source window like this:
newWindow = window.open("", "Compiler", "" );
doc = newWindow.document;
doc.open("text/html","replace");
doc.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">');
doc.writeln("<html>");
doc.writeln("<head>");
....
doc.writeln("</html>");
doc.close();
just as an idea to proceed.
This can't work in the way you designed it. Per definition, the loading of the new document in the new window is asynchronous, see here https://developer.mozilla.org/en-US/docs/Web/API/Window.open
So, the setting of a style immediately after the "open" call must fail, since the document with the according element ("compiler") must not be loaded at that time and likely will not be.
What you actually can do is, load the doc and wait for the onready event, but only in the new window, and do all the settings over there. You may also craft the document from the source window like this:
newWindow = window.open("", "Compiler", "" );
doc = newWindow.document;
doc.open("text/html","replace");
doc.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">');
doc.writeln("<html>");
doc.writeln("<head>");
....
doc.writeln("</html>");
doc.close();
just as an idea to proceed.
answered Dec 28 '14 at 7:34
Axel AmthorAxel Amthor
9,61611336
9,61611336
So I have to redo the whole document to make it work the way i want it to?
– user4375224
Dec 28 '14 at 7:38
add a comment |
So I have to redo the whole document to make it work the way i want it to?
– user4375224
Dec 28 '14 at 7:38
So I have to redo the whole document to make it work the way i want it to?
– user4375224
Dec 28 '14 at 7:38
So I have to redo the whole document to make it work the way i want it to?
– user4375224
Dec 28 '14 at 7:38
add a comment |
Abandoning window.open:
Create an iframe:
var compiler = document.createElement('iframe');
compiler.src = "mypage.html";
compiler.id = "compiler";
Put it where you want it to be:
document.getElementById("compilercontainer").appendChild(compiler);
Change it:
compiler = document.getElementById("compiler");
var comdoc = compiler.contentWindow.document;
var style = comdoc.createElement('style');
style.innerHTML = ".foo color:orange";
comdoc.head.appendChild(style);
This could probably be made neater with JQuery, but that isn't tagged (and I understand pure JS DOM manipulation better, personally)
ur first two lines are not working
– user4375224
Dec 28 '14 at 7:35
@Mohit.Bhasi works fine on Saf8 and Chrome39
– lucasem
Dec 28 '14 at 7:38
using chrome , removed the window.open , still not working
– user4375224
Dec 28 '14 at 7:41
Try"./mypage.html"and check for case ("MyPage.HTML") when this is a local file on a WIN system!
– Axel Amthor
Dec 28 '14 at 7:46
add a comment |
Abandoning window.open:
Create an iframe:
var compiler = document.createElement('iframe');
compiler.src = "mypage.html";
compiler.id = "compiler";
Put it where you want it to be:
document.getElementById("compilercontainer").appendChild(compiler);
Change it:
compiler = document.getElementById("compiler");
var comdoc = compiler.contentWindow.document;
var style = comdoc.createElement('style');
style.innerHTML = ".foo color:orange";
comdoc.head.appendChild(style);
This could probably be made neater with JQuery, but that isn't tagged (and I understand pure JS DOM manipulation better, personally)
ur first two lines are not working
– user4375224
Dec 28 '14 at 7:35
@Mohit.Bhasi works fine on Saf8 and Chrome39
– lucasem
Dec 28 '14 at 7:38
using chrome , removed the window.open , still not working
– user4375224
Dec 28 '14 at 7:41
Try"./mypage.html"and check for case ("MyPage.HTML") when this is a local file on a WIN system!
– Axel Amthor
Dec 28 '14 at 7:46
add a comment |
Abandoning window.open:
Create an iframe:
var compiler = document.createElement('iframe');
compiler.src = "mypage.html";
compiler.id = "compiler";
Put it where you want it to be:
document.getElementById("compilercontainer").appendChild(compiler);
Change it:
compiler = document.getElementById("compiler");
var comdoc = compiler.contentWindow.document;
var style = comdoc.createElement('style');
style.innerHTML = ".foo color:orange";
comdoc.head.appendChild(style);
This could probably be made neater with JQuery, but that isn't tagged (and I understand pure JS DOM manipulation better, personally)
Abandoning window.open:
Create an iframe:
var compiler = document.createElement('iframe');
compiler.src = "mypage.html";
compiler.id = "compiler";
Put it where you want it to be:
document.getElementById("compilercontainer").appendChild(compiler);
Change it:
compiler = document.getElementById("compiler");
var comdoc = compiler.contentWindow.document;
var style = comdoc.createElement('style');
style.innerHTML = ".foo color:orange";
comdoc.head.appendChild(style);
This could probably be made neater with JQuery, but that isn't tagged (and I understand pure JS DOM manipulation better, personally)
edited Dec 28 '14 at 7:49
answered Dec 28 '14 at 7:31
lucasemlucasem
321210
321210
ur first two lines are not working
– user4375224
Dec 28 '14 at 7:35
@Mohit.Bhasi works fine on Saf8 and Chrome39
– lucasem
Dec 28 '14 at 7:38
using chrome , removed the window.open , still not working
– user4375224
Dec 28 '14 at 7:41
Try"./mypage.html"and check for case ("MyPage.HTML") when this is a local file on a WIN system!
– Axel Amthor
Dec 28 '14 at 7:46
add a comment |
ur first two lines are not working
– user4375224
Dec 28 '14 at 7:35
@Mohit.Bhasi works fine on Saf8 and Chrome39
– lucasem
Dec 28 '14 at 7:38
using chrome , removed the window.open , still not working
– user4375224
Dec 28 '14 at 7:41
Try"./mypage.html"and check for case ("MyPage.HTML") when this is a local file on a WIN system!
– Axel Amthor
Dec 28 '14 at 7:46
ur first two lines are not working
– user4375224
Dec 28 '14 at 7:35
ur first two lines are not working
– user4375224
Dec 28 '14 at 7:35
@Mohit.Bhasi works fine on Saf8 and Chrome39
– lucasem
Dec 28 '14 at 7:38
@Mohit.Bhasi works fine on Saf8 and Chrome39
– lucasem
Dec 28 '14 at 7:38
using chrome , removed the window.open , still not working
– user4375224
Dec 28 '14 at 7:41
using chrome , removed the window.open , still not working
– user4375224
Dec 28 '14 at 7:41
Try
"./mypage.html" and check for case ("MyPage.HTML") when this is a local file on a WIN system!– Axel Amthor
Dec 28 '14 at 7:46
Try
"./mypage.html" and check for case ("MyPage.HTML") when this is a local file on a WIN system!– Axel Amthor
Dec 28 '14 at 7:46
add a comment |
well there are some issues here :)
1) jump to a new page using window.location="mypage.html" (remember the double quotes, single do as well)
2) you seem to forget about double quoting: document.getElementById("compiler").style.display="block";
3) you cannot refer to the "compiler" element from your function because when you get there, you have already loaded the new page.
You can do something like this:
window.location="mypage.html?id=compiler"
And in your mypage.html:
<head>
<script>
function display()
var id = parseURL();
document.getElementById(id).style.display="block";
function parseURL()
refer to: https://stackoverflow.com/questions/831030/how-to-get-get-request-parameters-in-javascript
</script>
</head>
<body onload="display()">
....
the idea is to pass the id of the element to be displayed to the new page via GET parameter and then get it back from the URL in the new page.
Refer to How to get "GET" request parameters in JavaScript?
Mauro
add a comment |
well there are some issues here :)
1) jump to a new page using window.location="mypage.html" (remember the double quotes, single do as well)
2) you seem to forget about double quoting: document.getElementById("compiler").style.display="block";
3) you cannot refer to the "compiler" element from your function because when you get there, you have already loaded the new page.
You can do something like this:
window.location="mypage.html?id=compiler"
And in your mypage.html:
<head>
<script>
function display()
var id = parseURL();
document.getElementById(id).style.display="block";
function parseURL()
refer to: https://stackoverflow.com/questions/831030/how-to-get-get-request-parameters-in-javascript
</script>
</head>
<body onload="display()">
....
the idea is to pass the id of the element to be displayed to the new page via GET parameter and then get it back from the URL in the new page.
Refer to How to get "GET" request parameters in JavaScript?
Mauro
add a comment |
well there are some issues here :)
1) jump to a new page using window.location="mypage.html" (remember the double quotes, single do as well)
2) you seem to forget about double quoting: document.getElementById("compiler").style.display="block";
3) you cannot refer to the "compiler" element from your function because when you get there, you have already loaded the new page.
You can do something like this:
window.location="mypage.html?id=compiler"
And in your mypage.html:
<head>
<script>
function display()
var id = parseURL();
document.getElementById(id).style.display="block";
function parseURL()
refer to: https://stackoverflow.com/questions/831030/how-to-get-get-request-parameters-in-javascript
</script>
</head>
<body onload="display()">
....
the idea is to pass the id of the element to be displayed to the new page via GET parameter and then get it back from the URL in the new page.
Refer to How to get "GET" request parameters in JavaScript?
Mauro
well there are some issues here :)
1) jump to a new page using window.location="mypage.html" (remember the double quotes, single do as well)
2) you seem to forget about double quoting: document.getElementById("compiler").style.display="block";
3) you cannot refer to the "compiler" element from your function because when you get there, you have already loaded the new page.
You can do something like this:
window.location="mypage.html?id=compiler"
And in your mypage.html:
<head>
<script>
function display()
var id = parseURL();
document.getElementById(id).style.display="block";
function parseURL()
refer to: https://stackoverflow.com/questions/831030/how-to-get-get-request-parameters-in-javascript
</script>
</head>
<body onload="display()">
....
the idea is to pass the id of the element to be displayed to the new page via GET parameter and then get it back from the URL in the new page.
Refer to How to get "GET" request parameters in JavaScript?
Mauro
edited May 23 '17 at 10:33
Community♦
11
11
answered Dec 28 '14 at 8:02
Mauro CioniMauro Cioni
33
33
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f27674425%2fhow-to-open-another-html-page-using-javascript%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Does the opened page have to be in a new tab/window?
– lucasem
Dec 28 '14 at 7:21
window.openreturn reference to new opened window– Grundy
Dec 28 '14 at 7:22
1
is
mypage.htmlan Object of the namemypageand the propertyhtmlholds the URL or are you just missing the quotes as it is already the namewindow.open("mypage.html");– Axel Amthor
Dec 28 '14 at 7:22
@AxelAmthor was missing the quotes
– user4375224
Dec 28 '14 at 7:24
@lucasem nope it should not be
– user4375224
Dec 28 '14 at 7:24