/    Sign up×
Community /Pin to ProfileBookmark

Javascript to do double action

I need some way with javascript to have a <a href=””> to go to a webpage then also go to an anchor tag <a label=””>.

So i need this to do 2 things.

For example. I have a link that when clicked changes an image on the top of the page but it if the link is down lower on the page you would not know it changed the image because it doesnt scroll up to view. I need a way to have it so when that link is clicked the image changes and the page scrolls up to the top. Any help is appreciated.

Thanks.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorJul 23.2009 — This will scroll the page up
<i>
</i>&lt;a href="#"&gt;

This will scroll the page to a certain anchor:
<i>
</i>&lt;a name="myanchor"&gt;&lt;/a&gt;
...
...
&lt;a href="#myanchor"&gt;link&lt;/a&gt;
Copy linkTweet thisAlerts:
@mluxauthorJul 23.2009 — Thanks but i already know how to do this with HTML. The problem is, is that there is already <a href being used to populate the image above. Below is the CF code im working with if that helps..

I have to apply this to an img and text link...

Image Link code:

<cfoutput><cfif len(attributes.imglink)><a href="#attributes.imglink#" #doMouseover(attributes.filealt)#></cfif><img src="#attributes.imgBase##subdir#/#attributes.filename#" id="#attributes.ImgID#" name="#attributes.ImgID#" onMouseOver="style.cursor='pointer'" onclick="#attributes.OnClick#" border="#attributes.border#" alt="#attributes.filealt#"<cfif isDefined("attributes.hspace")> hspace="#attributes.hspace#"</cfif><cfif isDefined("attributes.vspace")> vspace="#attributes.vspace#"</cfif><cfif len(attributes.align)> align="#attributes.align#"</cfif><cfif len(attributes.imgclass)> class="#attributes.imgclass#"</cfif><cfif len(attributes.style)> style="#attributes.style#"</cfif> /><cfif len(attributes.imglink)></a></cfif><cfif attributes.addbr><br/></cfif></cfoutput>


Text Link Code:

<h3 class="product" onMouseOver="style.cursor='pointer'" onclick="document.CategoryHeader.src='/images/#Enlrg_Image#'">#Name#</h3>
×

Success!

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