/    Sign up×
Community /Pin to ProfileBookmark

How do you pass a dynamically generated URL from one JS to HTML for another JS to use

I’m trying to pass a dynamically generated URL from one JavaScript, into my HTML page, so that another JavaScript can pick it up and use it.

Specifically, the first JavaScript file that generates the URL is:

[CODE]
function currentimglg() {
imagelg = “http://www.katherinellannin.com/images/pile_project/Pile_Project_” + x +”_lg.jpg”;
document.largeimg.href=imagelg;
}
[/CODE]

In my HTML page, I have the following code:

[CODE]<a href=”javascript:currentimglg();” name=”largeimg” target=’_blank’ onClick=’openit(this.href, “Pile Project”); return false’><img src=”javascript:void(currentimg();)” border=”0″ name=”gallery” /></a>[/CODE]

Finally, a second JavaScript file called openit should be useing the URL created by currentimglg in ‘openit(this.href, (above).

In case you need that JS file, it’s available here: [url]http://gil.davis.home.att.net/openit_example.htm[/url] – I haven’t made any changes to it.

But my issue is that the image URL isn’t printing into my HTML document. How do I get it to do that? document.write doesn’t work either (though I may have had the syntax wrong).

Thanks for your help!

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@tinuvielauthorMar 11.2009 — OKay, well I've discovered I have to merge the two JS's.

But now - how come the resizing isn't working properly? It's almost right, but it's a few numbers off - 50px too short on the bottom, and a few on the right. I don't understand the code the guy originally wrote, so I was wondering if anyone here could update it to today's browsers?

http://gil.davis.home.att.net/openit.js
×

Success!

Help @tinuviel 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.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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