/    Sign up×
Community /Pin to ProfileBookmark

Click to Reveal – A little help

Hello,

Firstly, I have found a script, I did a little bit of chopping and changing, and on a single page it works great as all of the javascript is currently internal, but I want to adapt the script a little bit.

Here are 2 scripts what resides in my <head></head>

[B]<script type=”text/javascript” language=”JavaScript”><!–
function HideContent(d) {
document.getElementById(d).style.display = “none”;
}
function ShowContent(d) {
document.getElementById(d).style.display = “block”;
}
function ReverseContentDisplay(d) {
if(document.getElementById(d).style.display == “none”) { document.getElementById(d).style.display = “block”; }
else { document.getElementById(d).style.display = “none”; }
}
//–></script>

<SCRIPT language=”JavaScript”>
<!–hide

function newwindow()
{
window.open(‘http://www.myshop.com/mylink.htm’,’jav‘);
}
//–>
</SCRIPT>[/B]

Here is the code that I use for my link in <BODY></BODY>:

[B]<a href=”javascript:newwindow();ShowContent(‘content’)”>Link to open page http://www.myshop.com/mylink.htm</strong></a></td>

<div id=”content” style=”display:none;”>THIS IS WHERE HIDDEN CONTENT WILL APPEAR WHEN MY LINK IS CLICKED</div>[/B]

When the link is clicked it reveals the content and opens a window to a new page/site.

What I want to do is to adapt the javascript so I am able to add more than 1 link I can open, and I want to make the <HEAD> javascript external. I tried to do it but the code wouldn’t reveal itself in the <div> tags in the body. Basically, I want to make use of it in a blog where all of the php files use the same header, so I am limited to the same script for every page.

Is it possible to add newwindow2 or something so I can add another link, and how do I make the link call onto an external javascript? Currently, as I see it, it is calling on the internal script.

So I would have something like:

I hope this makes sense, I am not too well up on javascript but I really need to get this working.

TIA
Terry ?

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

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