/    Sign up×
Community /Pin to ProfileBookmark

Creating bulleted list of web links

Attached is my source code for a practice we are doing with arrays. I am trying to make a bulleted list of the weblinks from a scripted paragraph. It works ok to make my bulleted list – but they are not the links – they are the web addresses.

Is there a way I can make this list a list of links? When I exchange the last line with this

document.write(“<li><a href=””, document.links[i].href, “”>”, document.links[i].text, “</a></li>”)

it locks up Netscape and “Not responding” shows up in the title bar. ?

Any help?
Thanks…………

[upl-file uuid=b22dc467-f692-4e25-8858-6c3ebb85c403 size=3kB]ChristmasList.txt[/upl-file]

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterApr 01.2005 — I don't understand what you're asking us to write for you.

I can make an array containing all of your URLs, but I don't know what you're after.

Also, let me point-out that there is no difference between document.write and document.writeln other than it adds an extra "n". This "n" is not a <br> --

if you want the real effect of document.writeln, you need to use it with a

<PRE></PRE> tag.
Copy linkTweet thisAlerts:
@felgallApr 01.2005 — Have you remembered to add the <ul> to the front of the list and the </ul> to the end of the list? If they are missing then the <li> tags are not correctly placed and most web browsers will not accept it.
Copy linkTweet thisAlerts:
@bathurst_guyApr 01.2005 — Is this what you mean?:

document.write("<h1><b>TOYS IN A BULITED LIST AS WEB LINKS</b></h1>")

//Write a script that displays a bulited list of links

var toylinks = "www.1966batmobile.com,www.atari.com/transformers/us/flash/flash-us.htm,www.hasbro.com/gijoe/default.cfm,disney.go.com/vault/archives/characters/buzz/buzz.html,www.shop.bt.com/icat/walkietalkies,www.originalskateboards.com,barbie.everythinggirl.com,www.hasbro.com/monopoly,www.hasbro.com/playdoh,www.minishop.com"
var toylinksArray = toylinks.split(",")

document.write("<ul>");

for (i=0; i<toylinksArray.length;i++)

{

document.write("<li><a href="http://", (toylinksArray[i]), "">", (toyArray[i]), "</a></li>");

}



document.write("</ul>");
Copy linkTweet thisAlerts:
@CharlesApr 01.2005 — &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;meta name="Content-Script-Type" content="text/javascript"&gt;
&lt;meta name="Content-Style-Type" content="text/css"&gt;
&lt;title&gt;Example&lt;/title&gt;

&lt;script type="text/javascript"&gt;
&lt;!--
if (document.getElementsByTagName) onload = function () {
var ul = document.createElement ('ul');

<i> </i>var l, i = 0;
<i> </i>while (l = document.links[i++]) {
<i> </i> var a = l.cloneNode(true);
<i> </i> var li = document.createElement ('LI');
<i> </i> li.appendChild (a);
<i> </i> ul.appendChild (li);
<i> </i>}

<i> </i>document.getElementsByTagName ('BODY')[0].appendChild (ul);
}
// --&gt;
&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;Typi non &lt;a href="fee"&gt;habent&lt;/a&gt; claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipitlobortis nisl ut aliquip ex ea commodo consequat. Lorem ipsum dolor sit &lt;a href="fie"&gt;amet&lt;/a&gt;, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut &lt;a href="foe"&gt;wisi&lt;/a&gt; enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipitlobortis nisl ut aliquip ex ea commodo consequat. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. &lt;a href="fum"&gt;Ut&lt;/a&gt; wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipitlobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. &lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@paupacgirlauthorApr 01.2005 — Okay, I can see where that would work - you are writing the elements of the array. What I was trying to do, was use the document.links array and pick up the website addresses from a few lines of text.....

Is that possible. Maybe I'll just skip the "script of text" and just make the list as you suggested.

If anything else comes to mind - I'm all ears............ ?

Thanks!
Copy linkTweet thisAlerts:
@paupacgirlauthorApr 02.2005 — Charles:

This is perfect! Exactly what I was looking for. Thanks!
×

Success!

Help @paupacgirl spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...