|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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)
|
|
#2
|
||||
|
||||
|
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>
|
|
#3
|
|||
|
|||
|
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? |
|
#4
|
||||
|
||||
|
The server isn't going to execute the javascript.
You might want to use a server-side language for that. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > search source code for particular sentence.. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|