umekille78 Posted March 13, 2006 Share Posted March 13, 2006 Hi all!I have a webbpage with a form on it.Im using onClick on a button to open a new window rather than using submit.The problem is that I dont know how to get the form data to be posted into the new window.Look att the exampel here: <input type=text name=username><br><input type="hidden" name="first" value=true><input type=button value="come on in" onClick=window.open("http://exampel/newpage.php?username&first");> Can anyone help me with this?/Per Link to comment Share on other sites More sharing options...
aspnetguy Posted March 13, 2006 Share Posted March 13, 2006 use <form target="_blank" ... instead Link to comment Share on other sites More sharing options...
umekille78 Posted March 13, 2006 Author Share Posted March 13, 2006 Hi again!I rather not use <form target="_blank" ...The purpose of using window.open is to be able to remove un wanted stuff like the URL list and forward and back buttons. Like this: <input type=button value="come on in" onClick=window.open("http://exampel/newpage.php?username&first",null,"height=600,width=800,status=yes,toolbar=no,menubar=no,location=no");> Can you do that with target="_blank" ??/Per Link to comment Share on other sites More sharing options...
aspnetguy Posted March 13, 2006 Share Posted March 13, 2006 how about this <script>function cForm(form){ win=window.open('','myWin','toolbars=0'); form.target='myWin';}</script><form action="http://google.com/search"> <input type="text" name="q"><p> <input name="submitButton" type="submit" value="Send" onclick="cForm(this.form)"> </p></form> Link to comment Share on other sites More sharing options...
scott100 Posted March 13, 2006 Share Posted March 13, 2006 Ok, so you want to type some text into a box, then open and new window and print the text from the box to that window?correct If so here ya go <html><head><script type="text/javascript">function myfunction(){var v = document.form1.Text_Box.value;var winPtr = window.open('', '_blank', '...features...');var str = '<html>\n';str += '<head>\n';str += '<title>Dynamic Page</title>\n';str += '</head><body><p>\n';str += v + '\n';str += '</p></body></html>';winPtr.document.open();winPtr.document.writeln(str);winPtr.document.close();}</script></head><body><form name="form1"><input type="text" NAME="Text_Box" /><input type="button" onclick="myfunction()" value="Print to new window"></form></body></html> Link to comment Share on other sites More sharing options...
umekille78 Posted March 13, 2006 Author Share Posted March 13, 2006 Hi all!The idea is that you should log on to a chatroom that I have made.I have a "login page" and a "chat page".What I want is to make the "login page" to open the "chat page" in a new window.It is important that the form data from the "login page" is transferd too the "chat page" in the new window.Any ideas? /Per Link to comment Share on other sites More sharing options...
aspnetguy Posted March 13, 2006 Share Posted March 13, 2006 try the example I previously gave. it submits the form to the new window and you can control what toolbars show up. <html><head></head><body><script>function cForm(form){win=window.open('','myWin','toolbars=0'); form.target='myWin';}</script><form action="chatpage.html" method="post"><input type="text" name="q"><p><input name="submitButton" type="submit" value="Send" onclick="cForm(this.form)"> </p></form></body></html> Link to comment Share on other sites More sharing options...
scott100 Posted March 13, 2006 Share Posted March 13, 2006 Well the most secure way of doing this is with a server side language like php or asp.With them it's a piece of cake to pass information.You can do what you want with javascript but it's not secure. Link to comment Share on other sites More sharing options...
aspnetguy Posted March 13, 2006 Share Posted March 13, 2006 Well the most secure way of doing this is with a server side language like php or asp.With them it's a piece of cake to pass information.You can do what you want with javascript but it's not secure. <{POST_SNAPBACK}> How secure does a chat program have to be??? Link to comment Share on other sites More sharing options...
scott100 Posted March 13, 2006 Share Posted March 13, 2006 How secure does a chat program have to be???<{POST_SNAPBACK}> well you could bypass the login script, it's pretty pointless with javascript. Link to comment Share on other sites More sharing options...
aspnetguy Posted March 13, 2006 Share Posted March 13, 2006 You could simple do an authentication check on the newly opened page (just like you would if you had used PHP for the whole thing. You would just do the check on opened page and not the original login page.The original question was how to get a form to submit to a new window. I am sure they took security into account. It really makes no difference the method you use as long as you do your security checks.BTW how would you ge the for to submit to a new window in PHP or ASP??? Wouldn't you just echo some javascript??? Link to comment Share on other sites More sharing options...
umekille78 Posted March 13, 2006 Author Share Posted March 13, 2006 If you should do it with PHP how would you do it then?/Per Link to comment Share on other sites More sharing options...
scott100 Posted March 13, 2006 Share Posted March 13, 2006 Important, both files must be in the same foldersave as login.html <FORM METHOD="LINK" ACTION="chat.html">Type your User Name: <INPUT TYPE="text" NAME="LastName"> <INPUT TYPE="submit" VALUE="Load Chat"></FORM> save as chat.html <FORM NAME="joe"><INPUT TYPE="hidden" NAME="burns"></FORM><script LANGUAGE="javascript">var locate = window.locationdocument.joe.burns.value = locatevar text = document.joe.burns.valuevar locate = window.locationdocument.joe.burns.value = locatevar text = document.joe.burns.valuefunction delineate2(str){point = str.lastIndexOf("=");return(str.substring(point+1,str.length));}var hi=delineate2(text);document.write("Loading Chat Room"); function go(){var winPtr = window.open('', '_blank', '...features...');var str = '<html>\n';str += '<head>\n';str += '<title>Dynamic Page</title>\n';str += '</head><body><p>\n';str += hi + '\n';str += ' has entered the room</p></body></html>';winPtr.document.open();winPtr.document.writeln(str);winPtr.document.close();}</SCRIPT> <body onload="go()"> Link to comment Share on other sites More sharing options...
scott100 Posted March 13, 2006 Share Posted March 13, 2006 BTW how would you ge the for to submit to a new window in PHP or ASP??? Wouldn't you just echo some javascript???<{POST_SNAPBACK}> Surely it can be done, i will investigate Link to comment Share on other sites More sharing options...
aspnetguy Posted March 13, 2006 Share Posted March 13, 2006 Well the most secure way of doing this is with a server side language like php or asp.With them it's a piece of cake to pass information.You can do what you want with javascript but it's not secure. <{POST_SNAPBACK}> I am confused Scott. Why did you say it is a piece of cake when you aren't sure how to do it?And what is the benefits of your script over mine? Why is it necessary to use a more complicated script to achieve the same thing? Link to comment Share on other sites More sharing options...
scott100 Posted March 13, 2006 Share Posted March 13, 2006 I am confused Scott. Why did you say it is a piece of cake when you aren't sure how to do it?<{POST_SNAPBACK}> I said: "With them it's a piece of cake to pass information" which it is.I just forgot to take the new window thing into considerationAnd what is the benefits of your script over mine? Why is it necessary to use a more complicated script to achieve the same thing?<{POST_SNAPBACK}> One of them didn't work and the other went to google which was fine, i just showed how to do it writing to a blank page with an old script i had kicking around. Link to comment Share on other sites More sharing options...
aspnetguy Posted March 13, 2006 Share Posted March 13, 2006 this one works, you can point it to whatever your processing page will be.http://w3schools.invisionzone.com/index.ph...indpost&p=14526 Link to comment Share on other sites More sharing options...
scott100 Posted March 13, 2006 Share Posted March 13, 2006 this one works, you can point it to whatever your processing page will be.http://w3schools.invisionzone.com/index.ph...indpost&p=14526<{POST_SNAPBACK}> Fair enough, i didn't realize, you never said Link to comment Share on other sites More sharing options...
umekille78 Posted March 14, 2006 Author Share Posted March 14, 2006 Hi again!I have tryed aspnetguy's script and it work realy well Thanks allot!! There is only one thing that dont work and that is the atribute "resizable=yes"I added this to tha features of the new window but I still can't resize it. Strange. win=window.open('','Chatt','height=600','width=800','status=no','toolbar=no','menubar=no','location=no','resizable=yes'); Can you se what is wrong with this. I need to be able to resize the window./Per Link to comment Share on other sites More sharing options...
aspnetguy Posted March 14, 2006 Share Posted March 14, 2006 win=window.open('','Chatt','width=800,height=600,status=no,toolbar=no,menubar=no,location=no,resizable=yes'); This is weird when I submit the post it is placing a & #39; in the code. Replace that with a quote ('). Odd I have never seen that before and connot get it to go away.try that Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now