JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old February 19th, 2005, 10:23 AM
confirm045 confirm045 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 28 confirm045 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 1 m 54 sec
Reputation Power: 0
search source code for particular sentence..

Is it possible to search the source code for a particular sentence (e.g <a href=file///c:/.../test.html) and convert it to just the file name of the <a href> target? (e.g <a href=test.html)

Reply With Quote
  #2  
Old February 19th, 2005, 04:19 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Something like this?

Code:
<html>
<script>
function getHrefList() {
	var result="";
	aList = document.getElementsByTagName('A');
	for(var i=0; i<aList.length;i++) {
		fullHref = aList.item(i).href;
		filename = fullHref.substring(fullHref.lastIndexOf("/")+1);
		result += filename + "<br/>\n";
	}
	return result;
}
</script>
<body>

<ul>
	<li><a href="http://www.example.com/page1.htm">Page 1</a></li>
	<li><a href="/path/to/page2.htm">Page 2</a><li>
	<li><a href="page3.htm">Page 3</a></li>
</ul>

<div>
<script>
document.write(getHrefList());
</script>
</div>

</body>
</html>

Reply With Quote
  #3  
Old February 20th, 2005, 09:39 AM
confirm045 confirm045 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 28 confirm045 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 1 m 54 sec
Reputation Power: 0
yeah. that worked really well. thanx.
But what if i was to upload several html files to a server and i want the server to automatically do the href conversion, in which part of the server codes do i put the Javascript?

Reply With Quote
  #4  
Old February 21st, 2005, 08:20 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
The server isn't going to execute the javascript.
You might want to use a server-side language for that.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > search source code for particular sentence..


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway