Saturday 15 May 2010

javascript - Use url name to set name of image -


I'm not sure this is possible, but I want to do the following:

Web pages have been found, which are called 1.html, 2.html, 3.html etc. Now I have the following code for 1.html:

  and object object width = "100%" data = "1.svg" type = "image / svg + xml" & gt;   

And for 2.html, I'll get 2.svg. e.t.c. Now I want to do something like this 100 pages, and I am thinking that it is possible to do it automatically using javascript or jquery? So something like this:

  and object object width = "100%" data = "[Here are some scripts that get the name of the HTM file.] SVG" type = "picture / SVG + XML "& gt;   

Any ideas?

Try it out:

jQuery

  var url = document.location.pathname; Url = url.substring (url.lastIndexOf ("/") + 1, url.lastIndexOf (".")); $ ('Object') Attr ('data', url + '.svg');   

JavaScript

  var url = document.location.pathname; Url = url.substring (url.lastIndexOf ("/") + 1, url.lastIndexOf (".")); Document.getElementsByTagName ('object') [0] .setAttribute ('data', url + '.svg');   

or this:

PHP

  object object = "& lt; php echo basename ( __ file__, ".html") ;? & gt; .svg "& gt; & Lt; / Object & gt;    

No comments:

Post a Comment