|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
variable use in image links to documents..
I have to link to a certain document. The name of the document should be grabbed from a xml file. For example, <a href="document12.pdf">Here is a link</a> with number 12 in a variable..
Also "Here is a link" should be a rollover image (a button), and not just a text. So there's the well-known rollover script in there too.. I tried this: <script type="text/javascript">var xmlDoc=new ActiveXObject("Microsoft.XMLDOM") xmlDoc.async="false"; xmlDoc.load("myfile.xml"); P=xmlDoc.documentElement.childNodes; document.write( "<a href='document"+ P.item(0).text + ".pdf' onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('imgdoc','','imgdocover.gif',1)"><img name="imgdoc" border="0" src="imgdoc.gif" width="149" height="50"></a>" ); </script> But I get an error: ") expected" in the document.write line The syntax is similar to an "img src" line (which works fine), so the variable and the xml is ok, just that it seems that it doesn't apply to "a href".. I don't know if this is the way to do it, so please help.. Thank you. |
|
#2
|
|||
|
|||
|
It's a Javascript thing, you forgot to put a backslash before the quotes in the document.write ("...") statement
Code:
<script type="text/javascript">
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("myfile.xml");
P=xmlDoc.documentElement.childNodes();
document.write( "<a href=\"document"+ P.item(0).text + ".pdf\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('imgdoc','','imgdocover.gif',1)\"><img name=\"imgdoc\" border=\"0\" src=\"imgdoc.gif\" width=\"149\" height=\"50\"></a>" );
</script>
|
|
#3
|
|||
|
|||
|
Thanks a lot!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > variable use in image links to documents.. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|