Jump to content

Open link in new window


zytex

Recommended Posts

hi i have this code

<form action onSubmit="return FrontPage_Form1_Validator(this)" language="JavaScript" name="FrontPage_Form1">
<p dir="ltr" style="text-align: center"> <font size="2" color="#000000"><strong><font color="#333333" size="3" face="Verdana, Arial, Helvetica, sans-serif"><span class=dirtitle>
<script type="text/javascript">
function cp_go( the_form ) {
if ( !the_form.channel.value ) { return; }
location = 'name=Forums&file=profile&mode=viewprofile&u='+the_form.channel.value;}
</script>
</span></font></strong><br>
<br>
Search User Profiles:<br>
</font><font size="1" face="Verdana"> <span style="background-color: #FFFFFF"><font color="#000000">
<input name="channel" type="text" class="input_field" style="height: 20px; width: 280px" size="20" maxlength="15">
(Enter the username of the chatter here)</font></span></font></p>
<p style="text-align: center"> <span style="background-color: #FFFFFF">
<font color="#008000" size="2" face="Verdana">
<input name="cplogin" class="login_but" type="button" onClick="cp_go(this.form)" value="Search For Profile" width="49" height="20">
<input name="rform" class="login_but" type="reset" onClick="cp_go(this.form)" value="Reset Form" width="49" height="20"></form>

</font></span>

and right now the profile gets open in the same window, i would like it to be opened in a new window. is this possible?
thanks,
Link to comment
Share on other sites

[!--quoteo(post=388973:date=Jun 28 2006, 03:38 PM:name=michaellunsford)--][div class=\'quotetop\']QUOTE(michaellunsford @ Jun 28 2006, 03:38 PM) [snapback]388973[/snapback][/div][div class=\'quotemain\'][!--quotec--]
it's not javascript.

<form action [b]target="_blank"[/b] onSubmit="return FrontPage_Form1_Validator(this)" language="JavaScript" name="FrontPage_Form1">
[/quote]

yeh i did that before thats why i asked were to put it because it dosn't work, it still opens in the same window
Link to comment
Share on other sites

okay, looking at the javascript, your culprate might be here:

[code]
location = 'name=Forums&file=profile&mode=viewprofile&u='+the_form.channel.value;}
[/code]

the "location" part emulates a header location redirect. redirects will not open new windows. you could replace that line of code with [code]window.open('name=Forums&file=profile&mode=viewprofile&u='+the_form.channel.value','_blank');[/code] and it should open a new window instead of redirecting. HOWEVER, you might have problems with popup blockers.

Keeping the target="_blank" in the <form> header, You could also try changing that line out with this:[code]document.forms[0].action = 'name=Forums&file=profile&mode=viewprofile&u='+the_form.channel.value;
return = true;
}[/code]
return = true should tell the form to submit to the new location.

if it gives you trouble, try adding a question mark before the name= part:
[code]document.forms[0].action = '?name=Forums&file=profile&mode=viewprofile&u='+the_form.channel.value; [/code]
Link to comment
Share on other sites

[!--quoteo(post=389050:date=Jun 28 2006, 08:12 PM:name=michaellunsford)--][div class=\'quotetop\']QUOTE(michaellunsford @ Jun 28 2006, 08:12 PM) [snapback]389050[/snapback][/div][div class=\'quotemain\'][!--quotec--]
okay, looking at the javascript, your culprate might be here:

[code]
location = 'name=Forums&file=profile&mode=viewprofile&u='+the_form.channel.value;}
[/code]

the "location" part emulates a header location redirect. redirects will not open new windows. you could replace that line of code with [code]window.open('name=Forums&file=profile&mode=viewprofile&u='+the_form.channel.value','_blank');[/code] and it should open a new window instead of redirecting. HOWEVER, you might have problems with popup blockers.

Keeping the target="_blank" in the <form> header, You could also try changing that line out with this:[code]document.forms[0].action = 'name=Forums&file=profile&mode=viewprofile&u='+the_form.channel.value;
return = true;
}[/code]
return = true should tell the form to submit to the new location.

if it gives you trouble, try adding a question mark before the name= part:
[code]document.forms[0].action = '?name=Forums&file=profile&mode=viewprofile&u='+the_form.channel.value; [/code]
[/quote]

thanks for all your help! but do you know why i might be getting error on page when i use

[code]<script type="text/javascript">
function cp_go( the_form ) {
if ( !the_form.channel.value ) { return; }
document.forms[0].action =
'name=Forums&file=profile&mode=viewprofile&u=+'the_form.channel.value;}
return = true;}
</script>[/code]

actually every way you stated above gave me error on page.
Link to comment
Share on other sites

try this:

change the "action" to the name of the file.
[code]<form method="get" action="post_to_location.html">
<input type="hidden" name="name" value="Forums">
<input type="hidden" name="file" value="profile">
<input type="hidden" name="mode" value="viewprofile">
  <p dir="ltr" style="text-align: center"> <font size="2" color="#000000"><strong><font color="#333333" size="3" face="Verdana, Arial, Helvetica, sans-serif"><span class=dirtitle>
                           
                            </span></font></strong>

                            Search User Profiles:

                            </font><font size="1" face="Verdana"> <span style="background-color: #FFFFFF"><font color="#000000">
                            <input name="channel" type="text" class="input_field" style="height: 20px; width: 280px" size="20" maxlength="15">
                            (Enter the username of the chatter here)</font></span></font></p>
            <p style="text-align: center"> <span style="background-color: #FFFFFF">
              <font color="#008000" size="2" face="Verdana">
              <input name="cplogin" class="login_but" type="button" onClick="cp_go(this.form)" value="Search For Profile" width="49" height="20">
              <input name="rform" class="login_but" type="reset" onClick="cp_go(this.form)" value="Reset Form" width="49" height="20"></form>
             
                        </font></span>[/code]

and cross your fingers. It might be using get and post (which would be tricky without using PHP).
Link to comment
Share on other sites

I forgot to remove the javascript from the submit and reset buttons. see if this works.

[code]<form method="get" action="post_to_location.html">
<input type="hidden" name="name" value="Forums">
<input type="hidden" name="file" value="profile">
<input type="hidden" name="mode" value="viewprofile">
  <p dir="ltr" style="text-align: center"> <font size="2" color="#000000"><strong><font color="#333333" size="3" face="Verdana, Arial, Helvetica, sans-serif"><span class=dirtitle>
                           
                            </span></font></strong>

                            Search User Profiles:

                            </font><font size="1" face="Verdana"> <span style="background-color: #FFFFFF"><font color="#000000">
                            <input name="channel" type="text" class="input_field" style="height: 20px; width: 280px" size="20" maxlength="15">
                            (Enter the username of the chatter here)</font></span></font></p>
            <p style="text-align: center"> <span style="background-color: #FFFFFF">
              <font color="#008000" size="2" face="Verdana">
              <input name="cplogin" class="login_but" type="submit" value="Search For Profile" width="49" height="20">
              <input name="rform" class="login_but" type="reset" value="Reset Form" width="49" height="20"></form></font></span>[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.