I've found a script that prints the variable on the page, but that isn't a lot of help to me, and I'm not too good with js, so my attempts at altering the script failed dismally
Javascript Url Variables
Page 1 of 18 Replies - 2840 Views - Last Post: 10 January 2013 - 08:52 AM
#1
Javascript Url Variables
Posted 23 October 2002 - 08:32 AM
basically, how do I grab a url variable with javascript and set it as a url?
I've found a script that prints the variable on the page, but that isn't a lot of help to me, and I'm not too good with js, so my attempts at altering the script failed dismally
I've found a script that prints the variable on the page, but that isn't a lot of help to me, and I'm not too good with js, so my attempts at altering the script failed dismally
Replies To: Javascript Url Variables
#3
Re: Javascript Url Variables
Posted 10 January 2013 - 06:11 AM
I am here!
I have got an idea about solution. Like if you have a div and want to turn all it's URLs into links( <a href="blalbha"> ), than just get text of that div in string, and use .split method. In that case you will get array of string, and use .forEach to check if there is any URLs. For that, just use this
Actually found this post here. And if in any string it returns true, just turn that string to URL. I think you can make changes in same array, after that just join that string using .join(" ")
I have got an idea about solution. Like if you have a div and want to turn all it's URLs into links( <a href="blalbha"> ), than just get text of that div in string, and use .split method. In that case you will get array of string, and use .forEach to check if there is any URLs. For that, just use this
function ValidURL(str) {
var pattern = new RegExp('^(https?:\/\/)?'+ // protocol
'((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|'+ // domain name
'((\d{1,3}\.){3}\d{1,3}))'+ // OR ip (v4) address
'(\:\d+)?(\/[-a-z\d%_.~+]*)*'+ // port and path
'(\?[;&a-z\d%_.~+=-]*)?'+ // query string
'(\#[-a-z\d_]*)?$','i'); // fragment locater
if(!pattern.test(str)) {
alert("Please enter a valid URL.");
return false;
} else {
return true;
}
}
Actually found this post here. And if in any string it returns true, just turn that string to URL. I think you can make changes in same array, after that just join that string using .join(" ")
#4
Re: Javascript Url Variables
Posted 10 January 2013 - 07:40 AM
you set a URL with document.location = "yourURL";
but what do you have so far? there is not enough information to understand what you want to do...
but what do you have so far? there is not enough information to understand what you want to do...
#5
Re: Javascript Url Variables
Posted 10 January 2013 - 08:03 AM
I think Spider may have moved on since he posted the question
..in 2002.
#6
Re: Javascript Url Variables
Posted 10 January 2013 - 08:10 AM
lol right... didn't notice the date of the post
/>
i was just watching today's new posts so i answered that one... geohot was missleading for me, sorry
i was just watching today's new posts so i answered that one... geohot was missleading for me, sorry
This post has been edited by Anthonidas: 10 January 2013 - 08:11 AM
#7
Re: Javascript Url Variables
Posted 10 January 2013 - 08:26 AM
#8
Re: Javascript Url Variables
Posted 10 January 2013 - 08:32 AM
Anthonidas why you down voted my post ? Isn't it helpful ?
Actually I think I must get banned for resurrecting dead post.
Actually I think I must get banned for resurrecting dead post.
#9
Re: Javascript Url Variables
Posted 10 January 2013 - 08:52 AM
geohhot, on 10 January 2013 - 04:32 PM, said:
Anthonidas why you down voted my post ? Isn't it helpful ?
Actually I think I must get banned for resurrecting dead post.
Actually I think I must get banned for resurrecting dead post.
No it isn't!
Firstly, you answered a question posted 11 years ago, and secondly, your post does not answer the question...
No one mentionned any bans... why should you be banned? Just because --> my personal feeling <-- is, that this post is not useful? Don't worry, you won't.
This post has been edited by Anthonidas: 10 January 2013 - 08:53 AM
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|