when i open a new window using window.open in firefox and try to navigate different section of the page within the new window using skip navigation does not work and preview window get reloaded.here is what i am doing.
<html>
<head>
<script>
function openWindow()
{
var win = window.open("","_blank");
win.document.write("<!DOCTYPE html><html><head></head><body><a href='#rajeev'>hi</a><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><div id='rajeev'>To Come Here</div></html>");
win.document.close();
}
</script>
</head>
<body>
<button type="button" onclick="openWindow()">Display Date</button>
</body>
</html>
You should be able to add the following onclick code to you link, instead of the hash:
You’ll need to import jQuery in the popup’s code, but if I just use this:
The browser seems to interpret the
</script>tag as the end tag for the whole “popup-writing” script.This can be circumvented by cutting up the
</script>tag in the strings, as seen below.This code works for me in Firefox and Chrome:
Now, you will only need to style the
<a>to make it look like you can click it, or replace it with a<button>, for example.(Stackoverflow kinda messes up the syntax highlighting in the code above, but it’s valid js. Also, you generally don’t want to add inline event listeners in your HTML.)