Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript to create a link

Status
Not open for further replies.

FabianoM

Programmer
May 13, 2009
2
Hello, I'm sorry for my English

I need to creat a link via javascript that pass the attribute rel:

I have the link:

<a href="#page.php" rel="history">PAGE LINK</a>

I need something that call a javascript function, for example:

<a href="javascript:pageURL('#page.php','history')>PAGE LINK</a>

where call the function


function pageURL(url, rel){

}

I don't know how to create in this function, I need creat the link with the href and rel attributes inside this function, and that in it same function execute the link automatically.

I need to do it, because I have to call it in the getURL of my flash menu, because the getURl don't suport the attribute rel.

Somebody can help me??

Thank's
 
Hi

Why would you need that [tt]rel[/tt] attribute ? The HTML 4.01 Specification | Basic HTML data types | Link types mentions no "history".

Anyway, the function you requested would be this :
Code:
[b]function[/b] pageURL(url, rel)
{
  [b]var[/b] a=document.createElement([i]'a'[/i])
  a.href=url
  a.rel=rel
  [b]return[/b] a
}
But no idea what could you do with it.

Feherke.
 
Perhaps Fabiano is mistaken and instead of create a 'link' (anchor) he wants to create a LINK element - which would make sense with a REL attribute?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Hi

Not to me. As I understand, he wants to make a request from Flash to jump to a given position in the document. The only reasonable element I can imagine would be an [tt]a[/tt] with [tt]name[/tt] attribute.

Feherke.
 
Hi

Thank you for reply, I believe that I was not very clear...

I must call a function through my onclick to create the link, and on the same function executes the link created automatically.

Explaining:

my link should be only with the onclick, because I want to make a function that creates the link and executes it automatically, because I will use this function on getURL of the flash that not support to pass the rel attribute.

I have the link:

Code:
<a href="#pagina.php" rel="history">PAGE LINK</a>

I want to transform it to something like this:

Code:
<a href="#" onclick="pageURL('page name','rel attribute');">PAGE LINK</a>

And in the function "pageURL" I want to create the link with the href and rel attributes and after executes it automatically, but don't only return it, I need that it opens the page automatically as if it had been clicked in link.

Explaining, I need to pass the rel attribute because I'm using a ajax function that open a page with the href and the rel attribute, with the simple link it's working, but I need to put it on Flash, that doesn't support the rel attribute in getURL.

Thank's


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top