Solved

JavaScript - open a new window from button click

Posted on 2010-11-30
6
337 Views
Last Modified: 2012-06-27
Hi,
I can't work out how to open a new window 900px wide by 800px high when the button is clicked?


<input name="button" type="button" class="formbutton_admin" id="button" onClick="javascript:preview_template(document.getElementById('template_name').value,document.getElementById('template_style').value)" value="Preview Template">


<script type="text/javascript">

function preview_template(name,style){      
            var name = name;
             var style = style;
            self.location = "preview.php?template_name="+name+"&style="+style;
}

 function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

</script>

Your comments and feedback would be appreciated.
0
Comment
Question by:sabecs
6 Comments
 
LVL 3

Expert Comment

by:chrios
ID: 34238645
Have a look at this link and see if it's of help to you.

http://javascript.internet.com/generators/popup-window.html
0
 
LVL 12

Expert Comment

by:rajapandian_81
ID: 34238736
Try below code:

<input name="button" type="button" id="button" onclick="window.open('HTMLPage1.htm', 'Template', 'width=900px, height=800px');" value="Preview Template" />

Open in new window

0
 
LVL 2

Accepted Solution

by:
sajjadz earned 500 total points
ID: 34238765
try the following code:
<html>
<body >

<input type=text name=template_name id=template_name value="test" />
<input type=text name=template_style id=template_style value="test" />
<input name="button" type="button" class="formbutton_admin" id="button" value="ok " onClick="javascript:openP();" />


<script language="javascript" type="text/javascript">
	function openPopup(url){
		my_win=window.open(url,'mywindow','width=900px,height=800px,left = 100,top = 200');  
	}
	
	function openP(){
		tname = document.getElementById('template_name').value;
		tstyle = document.getElementById('template_style').value;
		
	    var url = "preview.php?template_name="+tname+"&style="+tstyle;
		
	    openPopup(url);
	}
	

</script>
</body>
</html>

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Expert Comment

by:sajjadz
ID: 34238777
sorry, use "Preview Template" instead of "Ok" in button value
0
 
LVL 6

Expert Comment

by:Codebot
ID: 34238790
0
 

Author Closing Comment

by:sabecs
ID: 34238898
Thanks  sajjadz, its perfect..
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now