...

View Full Version : javascript new window



markman641
03-04-2012, 05:52 PM
I currently have my code set to this:


<a href=\"javascript:if(confirm('Are you sure this offer is not working and wish to report it?;?')){document,location.href='report.php?offername=".$row['name']."&offerid=".$row['offerid']."';}\">Report</a>

How would I make it so that:
1. It opens in a new window (target="_blank")??
2. I can define how big that window is

Thanks :)

Philip M
03-04-2012, 06:00 PM
You can't. Whether a page opens in a new tab, a new window or not at all is determined by the settings in the user's browser.


All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

webdev1958
03-04-2012, 10:47 PM
How would I make it so that:
1. It opens in a new window (target="_blank")??
2. I can define how big that window is

Thanks :)

1.

You can open a new window using window.open(). Also, nowadays it is generally considered bad practice to run javascript from a href attribute. Href's are meant for navigating to another another url and not for running javascript.

Best practice nowadays is to do something like this:


<a href="" onclick="runMyJsFunction(); return false;">Click me</a>The return false; aborts the default action of the <a> being to navigate to the url in the href.

Also, whether the page opens in a new window or a new tab in the browser is solely determined by what the user has chosen in their browser settings. You can't over-ride them.

The target element is generally deprecated now and so it shouldn't be used any longer, especially since it is no longer needed.

2.

Google window.open() and you should get a list of all the parameters you can use with window.open, which include parameters for sizing windows etc etc.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum