/    Sign up×
Community /Pin to ProfileBookmark

onclick include?

I have some problems with putting something in the link. I’m using on site such simple include construction:

[code=php]<?
switch ($_GET[‘go’])
{
case ‘2’:
include(“site2.htm”);
break;
case ‘3’:
include(“site3.htm”);
break;
case ‘1’:
default:
include(“site1.htm”);
}
?>[/code]

Simple link looks like this: <a href=”index.php?go=1″>site1</a>

I wonder is the a way to could make it as onclick event? Something like: <a onclick=”…”><img src=”…” /></a>?

I’m asking because I have some onclick JS function in links and I need add there also those include links but I’m not sure how it should look.

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@hastxApr 25.2007 — I think you want the header statement

[code=php]header("Location: http://www.example.com/");[/code]

the onClick handler would be:

[code=html]
<a href="#" onClick="location.href='http://www.example.com/'">Site</a>
[/code]

or
[code=html]
<a href="javascript:location.href='http://www.example.com/'">Site</a>
[/code]


the second one will display the link location in the status bar.
Copy linkTweet thisAlerts:
@AnnaccondauthorApr 25.2007 — No, unfortunately it's not what I'm searching for. I'm just trying find some simple way to solve this problem: http://www.webdeveloper.com/forum/showthread.php?t=146292

Links to style switcher looks like this:

<a onclick="setActiveStyleSheet('name of stylesheet'); return false;"><img src="some image.gif" /></a>

and I need add to it link to included content: "index.php?go=1". I can put both as href= but I wonder can I do it using onclick only ?
Copy linkTweet thisAlerts:
@hastxApr 26.2007 — I think I understand. One answer is to create a custom javascript function and then call that in the onClick, but when you click the link the page refreshes...reverting to the default style.

Don't people usually use an iframe or target a div tag for google ads? I don't know, i've never set them up, just asking.

what if you did:

onClick="location.href='index.php?go=1&activeStyle=title'";

then on the index page:

<body onLoad="setActiveStyleSheet(<?=activeStyle?>);">
Copy linkTweet thisAlerts:
@AnnaccondauthorApr 26.2007 — Yes I wanted make a function which would save values in cookie with active style but I'm not sure how to make it and no-one helped. I tried some ideas with AJAX, PHP and CSS but nothing worked as yet. Why google ads can't be easy customized using CSS? I can't even set background color to transparent ?

Maybe I'll try to make some PHP style switcher or whatever. I hope to find any solution of this problem.
×

Success!

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

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

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