Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-30-2007, 10:16 AM   PM User | #1
chris_angell
Regular Coder

 
Join Date: Jul 2002
Location: Brighton, UK
Posts: 282
Thanks: 1
Thanked 0 Times in 0 Posts
chris_angell is an unknown quantity at this point
adding rel attribute via javascript function href.

Hello I am trying to create the link below but to launch it via javascript but to include a "rel" value to the window.open or window.href ?? or anyway it is possible...

the link i am trying to replicate,,,,

<a href="link.htm" rel="700 200" title="Caption">Link</a>.

i have trid something like this but nothing ...??? but not working or even close,, i have tried to read up on attribute.rel.. but can't find much..

<script type="text/javascript">
functions link(RelLink,Relvalue,Relname){
window.open(RelLink, ['rel', Relvalue], Relname, 0);
}
</script>

many thanks chris
__________________
<marquee>thanks</marquee>

Last edited by chris_angell; 04-30-2007 at 10:18 AM.. Reason: forgot to add something...
chris_angell is offline   Reply With Quote
Old 04-30-2007, 11:07 AM   PM User | #2
shyam
Senior Coder

 
shyam's Avatar
 
Join Date: Jul 2005
Posts: 1,563
Thanks: 2
Thanked 163 Times in 160 Posts
shyam will become famous soon enough
dunno why u want to set a rel attribute...better take a look here http://www.w3schools.com/htmldom/met_win_open.asp
__________________
You never have to change anything you got up in the middle of the night to write. -- Saul Bellow
shyam is offline   Reply With Quote
Old 04-30-2007, 11:15 AM   PM User | #3
chris_angell
Regular Coder

 
Join Date: Jul 2002
Location: Brighton, UK
Posts: 282
Thanks: 1
Thanked 0 Times in 0 Posts
chris_angell is an unknown quantity at this point
Hi thanks for the reply.. but w3schools doesn't give me the info I am after...

It might sound a little abnormal to want to include a rel value, but i need to do this to run some script i have to run from actionscript!!

don't pose anyone who may know could write an example...
__________________
<marquee>thanks</marquee>
chris_angell is offline   Reply With Quote
Old 04-30-2007, 05:01 PM   PM User | #4
chris_angell
Regular Coder

 
Join Date: Jul 2002
Location: Brighton, UK
Posts: 282
Thanks: 1
Thanked 0 Times in 0 Posts
chris_angell is an unknown quantity at this point
I have tried a few ideas but i still can't get it to launch the link from a javascript onclick to change the rel ???

here is what I have tried..

<script type="text/javascript">
function link(LinkName, RelValue){
x=document.getElementById(LinkName);
x.rel = RelValue
window.href(LinkName, RelValue)
}
</script>
??????????????????????????????????????/

<a href="#" onclick="LinkName('link.htm','rel value')">test</a>



but man.. to have a link('page','rel value') is so hard... but to know how i can do this would be so so so so good

its a challange to you hardcore coders..



thanks you chris...
__________________
<marquee>thanks</marquee>
chris_angell is offline   Reply With Quote
Old 01-14-2009, 11:13 PM   PM User | #5
scotthaines
New to the CF scene

 
Join Date: Jan 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
scotthaines is an unknown quantity at this point
Here is your fix!

Chris,
I know you asked this question a few years back, but for anyone else looking to add the rel value into their code to utilize repeat functionality in DOM scripting cross site, here it is.

In my example, I am using a single div id and style to point my rss to many different dynamic rss zones on a website.

Here is the html.

<div id="subscribe-to-feed" rel="link to feed" class="float-right darklink">
<a href="link to feed" class="medtxt">subscribe</a><span class="margleftten"><img src="img/feed_ico.png" width="14" height="14" border="0"/></a>
</div>

Here is the JS

function dEI(obj){
return document.getElementById(obj);
}
(used to make life easier if not using the Prototype Lib, where the same is $)

if(dEI('subscribe-to-feed')){
dEI('subscribe-to-feed').onclick = function(){
window.location.href = dEI('subscribe-to-feed').getAttribute('rel');
}
}

Conclusion:
This will allow you to use css,html, and javascript in your coding using the principles of semantic web standards. By separating the javascript, and css, you make your life as a coder easier, and can run a lot of real neat tricks in the background of your site, without having to tell the user looking through your html source what those are. Granted, anyone with Firebug running can look at your javascript, but then hey, you just look like a better coder).

In this example, I didn't want to have to wrap the rss icon in another link, and wanted the user to be able to click anywhere within the rss div region to get the the page, however, this is only good for people with javascript, so by adding a default anchor in the actual html, it depreciates rather well.

Scott Haines
California Website Design and Development - Standards Based Web Applications

Last edited by scotthaines; 01-14-2009 at 11:16 PM.. Reason: wanted to add more explination to the conclusion
scotthaines is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:19 PM.


Advertisement
Log in to turn off these ads.