/    Sign up×
Community /Pin to ProfileBookmark

document.write Problem

Hello! I’ve been having some problems getting a document.write command working correctly. As a complete beginner in JavaScript I’m assuming it’s a syntax problem. Either that or I’m trying something really stupid.

My code currently has this line:

[CODE]document.write(‘<p><a target=”photo” href=’+'”‘+imagelinks[ry1]+'”‘+’><img src=”‘+myimages[ry1]+'” border=0></a></p>’)[/CODE]

Basically it prints the picture whose address is held in myimages[ry1] which is linked to the address in imagelinks[ry1]. When clicked, the link opens in a new window.

I want to edit this so that the window that opens is handled by JavaScript so I can get rid of the scrollbars etc. I can do this fine using Dreamweaver on a static image in HTML but am having trouble implementing this into this Javascript.

Here is my attempt (which doesn’t work!):

[CODE]function MM_openBrWindow(theURL,winName,features) {
window.open(theURL,winName,features);
}[/CODE]

[CODE]document.write(‘<p><a href=”#”><img src=”‘+myimages[ry1]+'” border=0 onClick=”MM_openBrWindow(‘+imagelinks[ry1]+’,’photo’,’width=300,height=300′)”></a></p>’)[/CODE]

Any ideas on how to correctly implement the “onClick=”MM_openBrWindow…” bit?

Thanks in advance,

T

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FromU2MEJan 01.2006 — This should work:

[CODE]var htmlcode = "<p><a href='#'><img src='" + myimages[ry1] + "' border=0 onClick="MM_openBrWindow('" + imagelinks[ry1] + "', 'photo', 'width=300, height=300');"></a></p>";

document.write(htmlcode);[/CODE]
Copy linkTweet thisAlerts:
@ThorntonReedauthorJan 01.2006 — Cheers mate. That's perfect.
×

Success!

Help @ThorntonReed 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 5.5,
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,
)...