Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a popup on a submit button.

Status
Not open for further replies.

alesisdrummer

Technical User
Nov 22, 2002
6
US
Hey, I was wondering if it is possible for an already existing submit button to have a small popup to show onClick. But it has to continue the other function and proceed to the shopping cart also. I just need some sort of javascript to allow this to happen. Any Ideas? Thanks a lot.
 
Code:
<input type="submit" [!]onclick="alert('onClick')"[/!] value="submit me" />

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
 
I'm actually looking for a small window to popup instead of an alert. Thanks for the idea though!
 
Code:
<input type="submit" [!]onclick="window.open('smallWindow.html')"[/!] value="submit me" />

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
 
Hmm..I checked that in both browsers and it opened a new tab. I just need a small popup that is about 500px by 500px. I'm getting so close, but no cigar yet. Please Please keep the ideas coming!! You are awesome!
 
Hmm..I checked that in both browsers and it opened a new tab.

That is likely because both browsers have a setting enabled to open new windows in a new tab. If a user has dictated that they want all new windows to open in a tab, there is no way for a javascript developer to overwrite that (and rightfully so - user's should get the final decision on their browser's behavior)

If you want a box to pop up on the screen then I'll suggest using an absolutely positioned <div> tag set to 500x500. This is considerably more difficult than using window.open - but it has been done 100s of times before and there will be examples all over google so I'd suggest trying there. A search for "div popup" or something similar should get you plenty of results.

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
 
But submitting the page will remove the "popup div", too. That would be a good idea to implement on the page submitted to, though.

Lee
 
But submitting the page will remove the "popup div", too.

Good point [smile]

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
 
Try this I use this trick for many uses.
var win;win=window.open('somewindow.html','window_name', 'scrollbars,resizable,width=500,height=500'); Using this trick will allow you to close the pop up from iside itself or even the opener may close the pop up with out that IE dialog "you are about to close a pop up"
Here is a page that will tell you all you need to know about the window object.
 
That doesn't address the problem of the window opening in a new tab that the OP wants to avoid. Please read the entire post to see what's been covered first.

Lee
 
You can not avoid that in some cases but I found that this code tidbit opens a new browser window almost every time to a new window the size you desire. So I am pretty sure this will address his issue. creating a variable for the window and naming it will help in most cases but to completely eliminate this problem is not entirely possible. I have a back up in these cases where I use a script to open a new window but it opens in a new tab and when you try and close the window you created it will not because it is a tab. So you got to trick the browser yet again. I take the opener back two in the history and close the window/tab and the user is back to where he was before he requested the image. Solving the open in a tab or window issue.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top