How to find and change part of html in IE6 by javascript -


i have webpage , need make changes in page. using ie6 in compatibility mode:

the part of html need change seems this:

<span title="klepnutím otevřete"        class=attachment url="/activities/attachment/download.aspx"        userid="{4618a8f6-8b8f-e611-940b-005056834715}"        merchantid="{74f4ac81-fb14-dc11-bf2e-00145ed73b3e}"        attachmenttype="5"        attachmentid="{1828327c-74a6-e611-940b-005056834715}">    <img border=0          src="/_forms/attachments/16_generic.gif"          align=absmiddle>&nbsp;account.xml </span> 

i change url else javascript.

is there way how it? know, there fuctions getelementbyid, can not use it, element not have id. seems, can not use xpath, not supported in ie6.

thanks replies!

you said you're getting this: object doesn't support property or method 'getelementsbyclassname'

that means document doesn't have method on it. here's polyfill method in older ies:

function getelementsbyclassname(node, classname) {     var = [];     var re = new regexp('(^| )'+classname+'( |$)');     var els = node.getelementsbytagname("*");     for(var i=0,j=els.length; i<j; i++)         if(re.test(els[i].classname))a.push(els[i]);     return a; } 

once function declared, can use it. remember it's not method on document in older browsers.

var spans = var tabs = getelementsbyclassname(document.body,'span');  for(var = 0; < spans.length; i++) {   var title = spans[i].getattribute('title');       if(title === "klepnutím otevřete") {         spans[i].setattribute('url', 'this/is/your/custom/url.aspx')      } } 

here, used title attribute try , find right span. have no idea if title unique span element, might need validate , select differently if needed.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -