lots of way possible ..
1.
<script language="javascript" type="text/javascript">
window.location.href="login.jsp?backurl="+window.location.href;
</script>
2.
<script language="javascript">
alert("back");
window.history.back(-1);
</script>
3.
<script language="javascript">
window.navigate("top.jsp");
</script>
4.
<script language="JavaScript">
self.location="top.htm";
</script>
5.
<script language="javascript">
alert("Access Violation");
top.location="error.jsp";
</script>
6.
<script language="javascript">
window.location = window.location.host;
</script>
Answer from Govind Singh on Stack Overflowlots of way possible ..
1.
<script language="javascript" type="text/javascript">
window.location.href="login.jsp?backurl="+window.location.href;
</script>
2.
<script language="javascript">
alert("back");
window.history.back(-1);
</script>
3.
<script language="javascript">
window.navigate("top.jsp");
</script>
4.
<script language="JavaScript">
self.location="top.htm";
</script>
5.
<script language="javascript">
alert("Access Violation");
top.location="error.jsp";
</script>
6.
<script language="javascript">
window.location = window.location.host;
</script>
check this question here.you can use
// similar behavior as an HTTP redirect
window.location.replace("http://stackoverflow.com");
// similar behavior as clicking on a link
window.location.href = "http://stackoverflow.com";
If you are trying to open a html file, from the same folder you can use the following javascript code :
location.replace("./name_of_the_file.html")
Don't forget the double quotes. If you want to open another website, you can use the following javascript code:
location.replace("https://stackoverflow.com")
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
Videos
This worked for me fine:
File 1:
<html>
<head></head>
<body>
<a href="#" onclick="window.open('file:///D:/Examples/file2.html'); return false">CLICK ME</a>
</body>
<footer></footer>
</html>
File 2:
<html>
...
</html>
This method works regardless of whether or not the 2 files are in the same directory, BUT both files must be local.
For obvious security reasons, if File 1 is located on a remote server you absolutely cannot open a file on some client's host computer and trying to do so will open a blank target.
window.location.href = 'file://///fileserver/upload/Old_Upload/05_06_2019/THRESHOLD/BBH/Look/chrs/Delia';
Nothing Worked for me.
In the main.html:
<input type='button' onclick='location.href=test.html' value='click me'>
in test.html
function create() {
// Write something in the page
}
<body onload='create()'>
</body>
function create()
{
window.location = 'test.html';
}
This is your starting point. Then, you need to add some PHP or JS to your test.html file.
Method 1: PHP
For example, you can get a message from the URL, that you're going to write.
Main file: function create() { window.location = 'test.php?p=Hello%World'; } Test file:
Method 2: JS
You can also write a JS function in your test file, which is called as soon as the page is loaded.
Main file:
function create() // Create function on 1st page
{
window.location = 'test.html';
}
Test file:
<head>
<script type="text/javascript">
function message()
{
document.getElementById('container').innerHTML = 'Hello world';
}
</script>
</head>
<body onload="message();">
<div id="container"></div>
</body>
Hope it helped.
Hello all !
I tried to open the index.html of a folder containing HTML and Javascript.
When I double click on the index.html, it's just a blank page.
What am I missing pls ?
Thank you so much !
In the HTML there is:
<html> <head> <title>My First Web Page</title> <script src="myComponents/index.js" type="module"></script> </head> <body> <my-audio src="https://alinkofsound.mp3"> </my-audio> </body> </html>
In my component folder, there is a javascript folder containing different elements to have the page do this.
The issue is that it works in codepenio..
I'm starting to question everything and want to finally understand stuff on a deeper level. So I'll start asking dumb questions.
My browser blocks the js code due to CORS. How could I allow it to run the js code? I want to understand step by step how we go from HTML and js code to a full web app. I want to understand each step, including bundlers and all of that.
Thanks for any suggestions.