Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listing URLS on a page

Status
Not open for further replies.

Nunners

Programmer
Aug 22, 2001
25
0
0
GB
All,

i have got some javascript which is meant to list the URL on a page, and relate them to thier LINK array number.

But it doesn't work, why else would i be posting the code here!!!

Any ideas...

!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>

<body>

<HTML dir=LTR>
<HEAD>
<TITLE></TITLE>




<!-- START OF SCRIPT -->
<!-- Takes away the underlining from the links -->
<STYLE TYPE=&quot;text/css&quot;>
<!--
A { text-decoration: none; }
A:link { color: #CEFFFF; }
A:visited { color: #CEFFFF; }
-->
</STYLE>
<!-- END OF SCRIPT -->
<BODY bgcolor=&quot;#313131&quot;>

<br>
<td></td>
<font color=&quot;#CEFFFF&quot;>

</HEAD>
<BODY leftMargin=&quot;0&quot; rightMargin=&quot;0&quot; topMargin=&quot;0&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; class=&quot;PageBG&quot;>

<TABLE >
<TR>
<TD>
<BR>
<A HREF=&quot; target=target_frame>Sales : Sales by Cat / Class / Dept</A>
<BR>
<A HREF=&quot; target=target_frame>Sales : Sales by Store HTD</A>
<BR>
<A HREF=&quot; target=target_frame>Sales : Sales by Store MTD</A>
<BR>
<A HREF=&quot; target=target_frame>Sales : Sales by Store WTD</A>
<BR>
</TD>
</TR>
</TABLE>
<table>
<tr>
<td></td>
</tr>
<tr>
<td><a href=&quot;PORTAL_LIVE.DYNAMIC_PRODUCT_SELECT.show?p_arg_names=_title&p_arg_values=Dynamic Product Select &quot;>Return to product group select</a></td>
</tr>
<tr>
<td></td>
</table>

<script language=&quot;JavaScript&quot;>
function listlinks(d) {
var newwin = window.open(&quot;&quot;,&quot;linklist&quot;,
&quot;menubar,scrollbars,resizable,width=600,height=300&quot;);

for (var i = 0; i < d.links.length; i++) {
newwin.document.write('<A href=&quot;' + d.links.href + '&quot;>')
newwin.document.write(d.links.href);
newwin.document.writeln(&quot;</A><BR>&quot;);

}
newwin.document.close();
}
</script>

<link href=&quot;parent.target_frame.export data&quot;
title=&quot;link to other page&quot;>

</font>
</BODY>
</HTML>
</body>
</html>

Thanks in advance

Nunners
 
I don't know if you are willing to restrict your answer to IE4 and above browsers, but here is one partial answer.

Here is a bookmarklet that I use in IE4 and above to list all links on ANY page. If you make it one of your favorites it can run as an javascript URL.

javascript:QB84x0=String.fromCharCode(34);WN7z6=open('','','width=400,height=200,scrollbars,resizable,menubar,status');DL5e=document.getElementsByTagName('a');with(WN7z6.document){write('<base%20target=_blank>');for(lKi=0;%20lKi<DL5e.length;%20lKi++){write('<a%20href='+QB84x0+DL5e[lKi].href+QB84x0+'>%20<b>'+DL5e[lKi].innerText+'</b><br><br>');};void(close())};

The SCRIPT form of it is:

<script language=&quot;JavaScript&quot;>

xnuline = String.fromCharCode(34);

var nuwin = open('', '', 'width=400, height=200, scrollbars, resizable, menubar, status');

var taglist = document.getElementsByTagName('a');
var i = 0;

with(nuwin.document)
{
write('<base target=_blank>');
for(i=0; i<taglist.length; i++)
{
write('<a href='
+ xnuline
+ taglist.href
+ xnuline
+ '> <b>'
+ taglist.innerText
+ '</b><br><br>');
};
void(close())
}
;
</script>

 
We are getting closer, Thanks for the srcipt Posterdot.

However the URL's are all displayed as &quot;undefined&quot;. This is the case for any web page i look at. Actually i have another related question.

I am trying to use the link[] array to click on a hyperlink within a different frame, I can get this to work for links within the same frame....like so.....

<a href =&quot;about:&quot;
onMouseOver=&quot;status = 'Links in nav frame.'; return true;&quot;
onMouseOut=&quot;status = '' &quot;
onClick=&quot;this.href =
document.links[1]&quot;
> Print to export
</A>

But, i would like to link to links with a frame i have called &quot;target_frame&quot;. Any ideas how this can be done easily???

i have tried...

<a href =&quot;about:&quot;
onMouseOver=&quot;status = 'Links in nav frame.'; return true;&quot;
onMouseOut=&quot;status = '' &quot;
onClick=&quot;this.href =
document.frame_target.links[1]&quot;
> Print to export
</A>

but that didn't work


Thanks, Nunners
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top