FRIHOSTFORUMSSEARCHFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

How change the property TARGET of tag A (LINK) using CSS?

 


mAyA_mOrAiS
How change the property TARGET of tag A (LINK) using CSS? Question
Please somebody send me an example!
Now I appreciate!Thank you very much!
Gushe
You simply can't. You'll have to use JavaScript for that, as is is the Behavior and not the Style of the webpage.

If you like, I can give you a JavaScript example.

~ Gushe
mAyA_mOrAiS
Yes,Please give me an example in Javascript!

Now I appreciate!Thank very much!


Very Happy Surprised Smile Shocked Laughing Question Idea
Gushe
Well, to make it more easy you should add an 'ID' property to your anchor element.

Let's say this is the anchor:
Code:
 <a id="Anchor1" class="link" href="www.frihost.org"> Go to Frihost!</a>


Than you should add the following piece of JavaScript to your header.
Code:
<script type="text/javascript">
var AnchorHandle = document.GetElementById('Anchor1');
AnchorHandle.onclick = AnchorHandle.href="www.frihost.com";
</script>


Or shorter:
Code:
<script type="text/javascript">
document.GetElementById('Anchor1').onclick = document.GetElementById('Anchor1').href="www.frihost.com";
</script>


Please note I'm still a noobie in JavaScript, so this might not be the best way do do this. Smile

Cheerios,
~ GuShe
mAyA_mOrAiS
This example creates a ID of links that open one same address, yes, it's great but what I want the same example changing the property TARGET for _BLANK because I need this for end my site !

When this finished I will put here.

Now I appreciate!Thank you very much!God bless you@

Very Happy Surprised Laughing Wink Cool Wink Arrow Idea Question Exclamation Smile
xcloudy
Gushe wrote:
Well, to make it more easy you should add an 'ID' property to your anchor element.

Let's say this is the anchor:
Code:
 <a id="Anchor1" class="link" href="www.frihost.org"> Go to Frihost!</a>


Than you should add the following piece of JavaScript to your header.
Code:
<script type="text/javascript">
var AnchorHandle = document.GetElementById('Anchor1');
AnchorHandle.onclick = AnchorHandle.href="www.frihost.com";
</script>


Or shorter:
Code:
<script type="text/javascript">
document.GetElementById('Anchor1').onclick = document.GetElementById('Anchor1').href="www.frihost.com";
</script>


Please note I'm still a noobie in JavaScript, so this might not be the best way do do this. Smile

Cheerios,
~ GuShe


You didn't anwer the question. maya asked for changing the 'target' property of a link , not the 'href' property.
Gushe
Let's not go pixelhugging. Change the 'href' into 'target' and you're done.
quasar
Code:


<html>
<head>
<script type="text/javascript">
function chg() {
var anchor = document.getElementById("Anchor1");
anchor.target = "my_win";
}
</script>
</head>
<body onload="chg()">
<a id="Anchor1" href="http://www.mysite.com">My site</a>
</body>
</html>


Related topics

HTML Tutorial.
[Guide] HTML and CSS
Invalid XHTML - Please help.
Rollover Buttons or Images
Windows Tips&tricks!

Web page links.
Battlefield 2 patch coming soon
Includ Images using PHP.
PHP POP3 webmail script
Who's using HTML Kit?

CSS/HTML
I want to be xhtml compliant...
FAQ system
Auto Targer Iframe
Need Help With CSS
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.