It certainly runs on IE6.
Why doesn't this JavaScript run in Mozilla Firefox?
<html>
<head>
<title>JavaScript Popup Example 3</title>
</head>
<SCRIPT language="JavaScript1.2">
function MyClass()
{
this.OpenWindow = function()
{
var r = window.open ('', 'mywindow', 'location=1,status=1,scrollbars=1,width=100,height=100');
r.moveTo(0,0);
r.location.href = 'http://www.google.com';
}
}
</SCRIPT>
<body onload="javascript: new MyClass().OpenWindow()">
<H1>JavaScript Popup Example 3</H1>
</body>
</html>
It runs just fine in my FF. For me the popup blocker is catching it.
Did you notice that little bar just below the tabs selection
alt text http://support.mozilla.com/img/wiki_up/86c0e1094489ddd5611008de57d0afed-1249166734-294-5.png
Check here for more information + images: FF Pop-up blocker
Just go to the FF menu -> option -> content -> block-pop-up-windows
Uncheck the option, click OK and try reload the page. It should now work fine for you. Also, don't forget to tick the check box again if you worry about security.
Related
I am trying to screenshot page created in new window, not popup but in new tab. Code now is simple. And page can be created.
However my goal is to make Full page screenshot of it. I used in Chrome - "Full Page Screen Capture " and in Firefox top screen captures - all of them greyed out - meaning impossible to capture entire page.
screenshot fialed
Code:
<!doctype html>
<head>
<title>New Window Screenshot</title>
</head>
<body>
<script>
function newWindow() {
var w = window.open('', '_blank');
w.document.write('Loading preview...');
}
</script>
<button onclick="newWindow()">Click me</button>
</body>
</html>
code
Please, no need of html2canvas. I just need to lunch some screencapturers. And my guess, well I don't know... Please help!
I have a question we must have seen many a time that when we are about to close the window and Just hover mouse over the cross on Browser Tab, a pop up appears asking for us to subscribe or highlighting some coupon. This Functionality is based on which feature of the browser, does it exploits some PHP code or some artificial intelligence.
It is run on client-side as everything that interact with user interface.
The example bellow shows how to do this with pure javascript (not tested with all browsers, but works well with Chrome)
<!DOCTYPE html>
<html>
<head>
<title>Page exit example</title>
<script type="text/javascript">
var showMessage = true;
window.onmouseout = function(){
if(showMessage){
showMessage = false;
document.getElementsByTagName('body')[0].innerHTML = "Dont leave yet!";
}
};
</script>
</head>
<body>
<h1>Hello world</h1>
</body>
</html>
In Javascript, I want to open my window.html file in a popup window. But it doesn't display any text. Just a blank page.
This is index.html:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<script language="javascript">
var newwindow;
function popit(url){
newwindow = window.open(
url, '', "status=yes, height=500; width=500; resizeable=0");
}
</script>
</head>
<body>
CLICK ME!
</body>
</html>
window.html:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>SAMPLE TEXT</p>
</body>
</html>
Why doesn't it display any text?
javascript:popit(window.html);
Replace with:
javascript:popit('window.html');
Your click handler code is syntactically incorrect:
CLICK ME!
Always, always have your developer console open to check for JavaScript errors! (edit — actually in this case there wouldn't have been an error; window.html would resolve to undefined probably! Still, keep the console open :-)
Also note that I used an "onclick" attribute instead of "href".
A GOOD working code with NO crashes.
Simple and what makes this code better is that you can use it in a JavaScript file separately and have it fairing to more then one file with the same popup size even though its different pages on popups.
Javascript
// Popup window code
function MyPopUp(url) {
popupWindow = window.open(
url,'popUpWindow','height=454,width=580,left=0,top=200,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
}
HTML
My PopUp
NOTE: You can also use this as onload in body for example <body onload="JavaScript:MyPopUp('MyDirectory/Page.html');"> and it will aslo work on onmouseover and others... though I do not advise this unless you want to piss off the clients visiting your page.
i'm want to open a file in background with javascript. The code works fine in chrome but in firefox (12) and Opera new windows open in foreground.
Anybody knows what i'm doind wrong?.
Here its code of two files:
father.html:
<html>
<body>
<script>
var son=null;
function openIt(){
son=window.open('son.html','sonpage');
son.blur();
self.focus();
window.focus();
//alert("voy");
return false;
}
</script>
Open
Close
<button type="button" id="play2-video" onclick="son.play()">
play2 video
</button>
<button type="button" id="pause2-video" onclick="son.pausa()">
pause video
</button>
Father Page
</body>
son.html:
<html>
<Head>
<script>
function play(){
alert("Play!");
}
function stop(){
alert("Stop!");
}
</script>
</Head>
<Body>
<h1> Son Page</h1>
</Body>
Thank you!
Firefox will only obey requests to raise a window if a security option
is set, and it's not set by default. Chrome won't pay attention to
focus() requests at all, as far as I can tell. Safari does obey
focus() request.
The specific Firefox setting is in the "Tools -> Options" dialog.
There's a "Content" tab, and in that there's a checkbox for enabling
Javascript. Along with that is an "Advanced" button that brings up
another dialog, wherein one finds a checkbox to allow (or disallow)
the raising and lowering of windows by page code.
read https://stackoverflow.com/a/2533335/643500
Tried to mess with the code -- no joy
The function only needs :
function openIt(){
son=window.open('son.html','sonpage');
window.focus();
return false;
}
Try to redirect back from the opened page to the main one and see if it can be accomplished that way?
Also, look into JQuery, it might handle that with events like http://api.jquery.com/focusout/
I have an HTML page that opens another page via JavaScript. When a user clicks a button in the other page, I want to post a message in a DIV of the opening page via JQuery. I cannot put my finger on it, but I cannot seem to get this to work. Here is my opener page
<html>
<head>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
</head>
<body>
<input type="button" onclick="window.open('dialog.html', '_blank', 'height=200, width=300');" value="launch!" />
<div id="testDiv"></div>
</body>
</html>
When the user clicks the "launch!" button, a dialog will appear. The code for the dialog looks like this:
<html>
<head>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
</head>
<body>
<input type="button" onclick="updateOpener()" value="Update Opener" />
<script type="text/javascript">
function updateOpener()
{
var testDiv = window.opener.jQuery("#testDiv");
if (testDiv != null) {
alert("here");
testDiv.html("Updated!");
}
}
</script>
</body>
</html>
Surprisingly, the alert box appears. However, I cannot seem to update the HTML of the DIV in my opening page. Does anyone know how to do this?
You're referencing "confirmDiv". Where is that DIV?
You can't do that if the parent page (the opener) resides on another domain. Otherwise, your code works perfectly.
Also, your != null check is probably not doing what you think it is doing, as the jQuery function never returns null. If you are checking for the existence of an element, you need to do it this way...
var el = $("#myElementId");
if(el.length == 0)
alert('Not found!');
Ummm, it works for me in Firefox 3.0.11, IE8 and Chrome 2... (I.e. the dialog.html button updates the HTML in the opener page to say 'Updated!'.)
Oddly, your example works fine for me in Chrome, IE 8 and FireFox. Do you have any other details?