/    Sign up×
Community /Pin to ProfileBookmark

Simple Script doesnt work with Google Chrome

Works fine with ie and firefox. All the script is there to do is open a new window but delayed so that users can see the button unpress.

Javascript:

[CODE]
var url2;
function popup(url)
{
url2 = url;
params = ‘width=’+screen.width;
params += ‘, height=’+screen.height;
params += ‘, menubar=yes’;
params += ‘, location=yes’;
params += ‘, resizable=yes’;
params += ‘, directories=yes’;
params += ‘, toolbars=yes’;
params += ‘, top=0’;
params += ‘, left=0’;
params += ‘, status=yes’;
params += ‘, scrollbars=yes’;

setTimeout(“window.open(url2,’windowname4′, params)”,500);

}

[/CODE]

html

[QUOTE]

<span class=”webdeveloper” title=”Webdeveloper” onmouseup=”this.style.backgroundPosition =’top’,popup(‘www.webdeveloper.com’)” onmouseover=”this.style.cursor=’pointer'” onmousedown=”this.style.backgroundPosition =’bottom’,style.cursor=’pointer'”>Press Me!</span>

[/QUOTE]

This is my favourite way of doing things.
The problem is that Chrome wont do a window.open launched from a set timeout.

(buttons are an image background that shows just half of the image at a time)

But its nerfed if i cant get it to work on 0.00005% of the browsers that visits the sites! (ive come to really dislike chrome)

Please help!

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@letmehaveagoJul 15.2010 — Yeah chrome blocks the popup.

A hack would be:

[CODE]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>
Conforming XHTML 1.0 Transitional Template
</title>
</head>

<body>
<p>
<script type="text/javascript">
<!--

function openWindow() {
var form = document.createElement('form');
document.body.appendChild(form);
form.method = 'get';
form.action = 'http://www.webdeveloper.com/';
form.target = '_blank';
setTimeout(function() {
form.submit();
}, 1000);
}
//-->
</script>
<input type="button" onclick="openWindow()" value="open" />
</p>
</body>

</html>
[/CODE]
Copy linkTweet thisAlerts:
@BelrickauthorJul 15.2010 — Excellent hack.

Thankyou immeasurably.

*bloody chrome, mumble mumble*
Copy linkTweet thisAlerts:
@ComputerAngelJul 28.2010 — The solution provided does not solves the problem. Chrome still blocks the popups. Any help please
Copy linkTweet thisAlerts:
@BelrickauthorJul 29.2010 — The problem is purely the delayed windows.open by using setTimeout.

I found that the hack provided worked with:

ie

chrome

firefox

But did not work with firefox.

So in the end I gave up and stopped using delayed windows open. Annoying but wasnt prepared to use scripts to determine browser type then load the appropriate function.
Copy linkTweet thisAlerts:
@FangJul 29.2010 — The OP's script works in all browsers. I suspect add-ons or changed browser options are blocking the popup.
Copy linkTweet thisAlerts:
@letmehaveagoAug 01.2010 — Yep, just tested in ff 3.6.8 and works!
×

Success!

Help @Belrick spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...