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 Overflow
Discussions

javascript - Open a new HTML page in a JS function and then write some HTML on it - Stack Overflow
I read about window.open() but I guess this is just a pop up, and I want a full-fledged page. ... Concept is flawed...javascript on first page is gone when new page loads. Need more details of use case to sort out best approach. Using dynamic server side language to generate the html is one simple way ... Please add more details and the code ... More on stackoverflow.com
🌐 stackoverflow.com
How can I open an HTML page with javascript in it?
It seems you may have included a screenshot of code in your post " How can I open an HTML page with javascript in it? ". If so, note that posting screenshots of code is against r/learnprogramming 's Posting Guidelines (section Formatting Code): please edit your post to use one of the approved ways of formatting code . (Do NOT repost your question! Just edit it.) If your image is not actually a screenshot of code, feel free to ignore this message. Automoderator cannot distinguish between code screenshots and other images. Please, do not contact the moderators about this message. Your post is still visible to everyone. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/learnprogramming
12
0
October 16, 2022
How do you open HTML file in javascript? - Stack Overflow
So, firstly I'd like to specific that I'm aware of the following code window.open(url); which has worked very well for me in the past. The problem this time is that I'm trying to open a html fil... More on stackoverflow.com
🌐 stackoverflow.com
July 9, 2016
JavaScript Button cannot open another html file. Why? - JavaScript - SitePoint Forums | Web Development & Design Community
Hello all, I am trying to set up an onclick function in Javascript that opens another html file. Below there are a few examples of the code used and the error messages they received. Please note that it must be a button not a hyperlink and also it needs to be the genuine file that opens not ... More on sitepoint.com
🌐 sitepoint.com
0
June 24, 2009
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Window › open
Window: open() method - Web APIs | MDN
November 30, 2025 - const windowFeatures = "left=100,top=100,width=320,height=320"; const handle = window.open( "https://www.mozilla.org/", "mozillaWindow", windowFeatures, ); if (!handle) { // The window wasn't allowed to open // This is likely caused by built-in popup blockers.
🌐
W3Schools
w3schools.com › jsref › met_doc_open.asp
HTML DOM Document open() Method
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
🌐
Reddit
reddit.com › r/learnprogramming › how can i open an html page with javascript in it?
r/learnprogramming on Reddit: How can I open an HTML page with javascript in it?
October 16, 2022 -

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..

Find elsewhere
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › HTML › How_to › Add_JavaScript_to_your_web_page
Add JavaScript to your web page - HTML | MDN
Within a browser, JavaScript doesn't do anything by itself. You run JavaScript from inside your HTML webpages. To call JavaScript code from within HTML, you need the <script> element.
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › javascript fundamentals
Hello, world!
If we have a lot of JavaScript code, we can put it into a separate file. Script files are attached to HTML with the src attribute:
🌐
W3Schools
w3schools.com › js › js_whereto.asp
JavaScript Where To
Old JavaScript examples may use a type attribute: <script type="text/javascript">. The type attribute is not required. JavaScript is the default scripting language in HTML. A JavaScript function is a block of JavaScript code, that can be executed when "called" for.
🌐
WebPlatform
webplatform.github.io › docs › tutorials › your_first_look_at_javascript
Your first look at JavaScript · WebPlatform Docs
To execute JavaScript in a browser you have two options — either put it inside a script element anywhere inside an HTML document, or put it inside an external JavaScript file (with a .js extension) and then reference that file inside the HTML document using an empty script element with a ...
🌐
Stack Overflow
stackoverflow.com › questions › 38283396 › how-do-you-open-html-file-in-javascript
How do you open HTML file in javascript? - Stack Overflow
July 9, 2016 - It had the same effect except that a small window was opened up briefly beforehand. ... You can't use direct ajax query for this url (crossdomain policy). So you must use proxy with jsonp. See: Loading cross domain endpoint with jQuery AJAX · And working example for you: http://jsbin.com/bahigodiru/1/edit?html,js,output
🌐
SitePoint
sitepoint.com › javascript
JavaScript Button cannot open another html file. Why? - JavaScript - SitePoint Forums | Web Development & Design Community
June 24, 2009 - Hello all, I am trying to set up an onclick function in Javascript that opens another html file. Below there are a few examples of the code used and the error messages they received. Please note that it must be a button not a hyperlink and also it needs to be the genuine file that opens not ...
🌐
W3Schools
w3schools.com › jsref › met_win_open.asp
Window open() Method
Animation Events Clipboard Events Drag Events Events Focus Events HashChange Events Input Events Keyboard Events Mouse Events PageTransition Events PopState Events Progress Events Storage Events Touch Events Transition Events Ui Events Wheel Events HTML Event Properties · altKey (Mouse) altKey (Key) animationName bubbles button buttons cancelable charCode clientX clientY code ctrlKey (Mouse) ctrlKey (Key) currentTarget data defaultPrevented deltaX deltaY deltaZ deltaMode detail elapsedTime elapsedTime eventPhase inputType isTrusted key keyCode location metaKey (Mouse) metaKey (Key) newURL oldURL offsetX offsetY pageX pageY persisted propertyName relatedTarget relatedTarget screenX screenY shiftKey (Mouse) shiftKey (Key) target targetTouches timeStamp touches type which (Mouse) which (Key) view HTML Event Methods
🌐
IQCode
iqcode.com › code › javascript › how-to-open-html-file-with-javascript
how to open html file with javascript Code Example
February 15, 2022 - // In my case, I used a button to activate this function: function myFunction() { window.location.href = 'index.html'; } ... Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond. Sign up · Develop soft skills on BrainApps Complete the IQ Test ... open javascript file for html how to open a html page in javascript using js to open htm file How do I open a JavaScript file in my browser?
🌐
W3Schools
w3schools.com › html › html_scripts.asp
HTML JavaScript
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
🌐
Reddit
reddit.com › r/web_design › beginner: why can't i just click on an html file and load the js code and test an app that way in the browser? why is a local server needed?
r/web_design on Reddit: Beginner: Why can't I just click on an HTML file and load the js code and test an app that way in the browser? Why is a local server needed?
February 15, 2022 -

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.

🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-add-javascript-to-html
How to Add JavaScript to HTML for Beginners | DigitalOcean
July 14, 2025 - The <script> tag can be placed in the <head> section of your HTML or in the <body> section, depending on when you want the JavaScript to load. Generally, JavaScript code can go inside the document <head> section in order to keep it contained and out of the main content of your HTML document.
🌐
Educative
educative.io › answers › how-to-open-a-link-in-a-new-tab-with-html-and-javascript
How to open a link in a new tab with HTML and JavaScript
HTML’s target="_blank" is the simplest method to open links in a new tab, requiring no additional scripting. JavaScript provides dynamic control using window.open(), making it ideal for programmatically opening links in new tabs.