473,408 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

opening new window on click of button

I don't have much background with javascript and my page currently is mainly using php. I am now trying to create a button that will open a new window and I believe I have to use javascript for that. I've looked online for help and it seems that I should be using window.open function but I keep on getting errors. Here is what I have so far.
Expand|Select|Wrap|Line Numbers
  1. echo '<form>';
  2. echo '<p><input type="button" value="Click Here" onClick="window.open('http://intra.array.ca/admin/ts2/tsreport.php','','width=900,height=600')"/></p>';
  3. echo '</form>';
  4.  
when I tried adding in the language=javascript thing it tells me I have an error with a "<" and my current coding, it tells me I have an error with a ";
or ",". Any help is appreciated. Thanks in advance.
Jun 16 '09 #1
4 3222
okay. I seemed to have figured it out without the use of window.open=)
Jun 16 '09 #2
acoder
16,027 Expert Mod 8TB
So, what did you use instead?

The problem with the code posted is that you've not escaped the single quotes.
Jun 16 '09 #3
i just used
Expand|Select|Wrap|Line Numbers
  1. echo '<form action="http://blah.php" target="_blank">
  2. <input type=submit value="click here">
  3. </form>';
  4.  
and where was I supposed to escape the single quotes..i must be blind..lol
Jun 16 '09 #4
acoder
16,027 Expert Mod 8TB
Since you use single quotes for the echo, you need to escape all single quotes within the string:
Expand|Select|Wrap|Line Numbers
  1. echo '<p><input type="button" value="Click Here" onclick="window.open(\'http://intra.array.ca/admin/ts2/tsreport.php\',\'\',\'width=900,height=600\')"/></p>';
Your code will also work, but you have more control with window.open(). To avoid the quotes problem, keep the JavaScript code out of HTML, or come out of PHP when you output HTML.
Jun 17 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Clara | last post by:
Hi,... I meant to write an application where there is a button in a window and when you click on the button, it will open a new window, but I want the first window to close, replaced by the second...
7
by: Evan Kontos | last post by:
I am using the window.open function to open a small window and I am using GET to get values back from that window. I want to be able to open another from the second window but I get an error...
44
by: Carlos Andr?s | last post by:
Hi everybody. I've got a problem. I'd like to avoid opening a new window when you have pressed the shift key and you click in the left button of the mouse. I've tried the next solution, in the...
14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
2
by: Matt Hamilton | last post by:
I have an application page with a datagrid with a checkbox on each row. The user should check the rows they want to modify and then click a button. When the button is clicked, I have a Click...
6
by: SkeanDu | last post by:
Ok, here is my problem. I have an aspx page that displays a databound datagrid and in one of the datagrid column headers I have an image that when clicked opens up a modal web dialog (another...
2
by: Peter W Johnson | last post by:
Hi Guys, I have a problem opening a child window within a parent window when passing a variable between two child windows. I have the parent window setup with two menuitems. The first calls...
1
by: coolsidsin | last post by:
I have a apsx form (Form A), which on submiting does a time consuming task. So i want to open a new aspx window (Form B) in which I want do do that time consuming task and show progress to the user...
3
by: Andrew Poulos | last post by:
There's a HTA application that's running on a local computer (not from a URL) and the user can open a new HTML window by clicking a button The first time the user clicks the button the window...
1
by: deararuns | last post by:
i hav a window wit a button and text box.. Then am opening a new window... suppose if i type somethin in a first window's text box.. and click the button.. the value typed in the text box shoult...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.