freelanceprogrammers.org Forum Index » Cold Fusion

JavaScript question


View user's profile Post To page top
rgpg_99 Posted: Tue Apr 12, 2005 3:04 pm


Joined: 01 Apr 2005

Posts: 16
JavaScript question
Hi all,

I have an input textbox where users would enter a URL. I want to have a
button next to the textbox that would test that URL by opening it in a
textbox. This is the code I have:

<form>
<input type="text" name="preview" value="preview">
<input type="button" name="previewText" value="Preview"
onclick="javascript:previewText()">
</form>

<script language=`JavaScript`>
<!--
function previewText()
{
window.open("","Preview","width=400,height=150,scrollbars=yes,resizable=yes,stat
us=0");
}
//-->
</script>


My question: how can I pass the value of the "previewText" textbox to the
URL portion of the "window.open" command, so that that URL is open in the
popup window?

Or, any other suggestion to achieve the same functionality (to check that a
URL works)?

Thanks in advance,

Roberto Perez
rgpg@...
Reply with quote
Send private message
View user's profile Post To page top
rgpg_99 Posted: Fri Apr 15, 2005 9:26 pm


Joined: 01 Apr 2005

Posts: 16
JavaScript question
At 07:30 PM 4/15/05, sgriffin_usa wrote:

>Don`t know if you have an answer to this yet, but this works for me.
>
><script language="javascript">
><!--
>function CheckURL(url){
>
>window.open(url,"Preview","width=400,height=150
>,scrollbars=yes,resizable=yes,status=0");
>
> }
>//-->
></script>
>
><form name="testfrm">
> <input type="text" name="test"/>
> <input type="button" name="check" value="Check URL"
>onclick="javascript:CheckURL(document.testfrm.test.value);"/>
></form>


Thanks a lot, that worked. One problem (bug?) I`ve noticed: if the user
does not enter the "http://" portion, the url is treated as a webpage, and
the button tries to open something like "http://www.mysite.com/urlHere"
which obviously is not recognized as a valid URL. Is there any way of
forcing something like "www.site.com" to behave as "http://www.site.com"?

Thanks in advance,

Roberto Perez
rgpg@...
Reply with quote
Send private message
View user's profile Post To page top
arrow_us_dc Posted: Thu Apr 21, 2005 9:10 pm


Joined: 21 Apr 2005

Posts: 2
JavaScript question
Robert

You can use javascript to check for the http:// prefix in the url
variable if it does not exist just add the http://prefix to the url
and you will get the desired functionality.

Can be easily done in javascript.

Thanks
Arjun



--- In cold_fusion@yahoogroups.com, Roberto Perez <rgpg@t...> wrote:
> At 07:30 PM 4/15/05, sgriffin_usa wrote:
>
> >Don`t know if you have an answer to this yet, but this works for
me.
> >
> ><script language="javascript">
> ><!--
> >function CheckURL(url){
> >
> >window.open(url,"Preview","width=400,height=150
> >,scrollbars=yes,resizable=yes,status=0");
> >
> > }
> >//-->
> ></script>
> >
> ><form name="testfrm">
> > <input type="text" name="test"/>
> > <input type="button" name="check" value="Check URL"
> >onclick="javascript:CheckURL(document.testfrm.test.value);"/>
> ></form>
>
>
> Thanks a lot, that worked. One problem (bug?) I`ve noticed: if the
user
> does not enter the "http://" portion, the url is treated as a
webpage, and
> the button tries to open something
like "http://www.mysite.com/urlHere"
> which obviously is not recognized as a valid URL. Is there any way
of
> forcing something like "www.site.com" to behave
as "http://www.site.com"?
>
> Thanks in advance,
>
> Roberto Perez
> rgpg@t...
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help