PDA

View Full Version : how to get URL details...


homerUK
11-28-2002, 10:04 AM
Hi,

Here is the scenario.. I have a iFrame which people can enter hyperlinks in.... they highlight the text, and press the link button. I can add the link and everything but I want to be able to add style info.
To do this, I need to check if the hyperlink already has a style tag attached to it.
so it would look something like:


<a href="aaa.htm" target="_blank" style="text-decoration:none">hello</a>


I am using the following code:


link = window.opener.iView.document.selection.createRange().parentElement();


which can then be used like:

link.href would return "aaa.htm"
link.target would return "_blank"

but I would have thought that

link.style would return "text-decoration:none" but it only seems to return "[object]"

Any ideas on how I get the value of "style"??

Many Thanks.....

Roelf
11-28-2002, 10:06 AM
for (x in link.style){
alert (x + "=" + link.style[x]);
}

homerUK
11-28-2002, 10:18 AM
hey, thanks for the fast response!!

I tried your code, and it took a life time to get go through all the alert boxes.. so I change it to document.write the results... from your test, the following results came up...(these are the only ones that returned values out of the whole massive list)


cssText=TEXT-DECORATION: none

textDecoration=none

textDecorationNone=true

My question now is... if I want to populate a field in my form now... I would use:

properties.style.value = link.style;

where properties is the form name, style is the textfield name and the link.style is the (hopefully) "text-decoration:none"part....

how do I actually get the value from the code you gave me?

Cheers v much!! :thumbsup:

glenngv
11-28-2002, 10:29 AM
if you want the style textfield to exactly have the value of "text-decoration:none", then the code should be:

properties.style.value = "text-decoration:"+link.style.textDecoration;

if you want just "none", then:

properties.style.value = link.style.textDecoration;

Roelf
11-28-2002, 11:03 AM
Originally posted by homerUK
I tried your code, and it took a life time to get go through all the alert boxes..
:D

and i think you are creating a problem, using style as a fieldname. When adressing this field, using the formname.fieldname method, you could be accessing the style property of the form instead of the field with the name "style". Don't know for sure but you could try changing it

homerUK
11-28-2002, 01:06 PM
thanks for all the help! I got it all working perfectly now!!
I can now update the COLOR and TEXT-DECORATION on the link!!

Cheers guys!! :thumbsup: