Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    Brighton, UK
    Posts
    282
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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
    Last edited by chris_angell; 04-30-2007 at 10:18 AM. Reason: forgot to add something...
    <marquee>thanks</marquee>

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    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

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    Brighton, UK
    Posts
    282
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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>

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Location
    Brighton, UK
    Posts
    282
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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>

  • #5
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •