ivanopalas
asked on
replace all <span .... > </span> to < div ......> </div> everywhere on page by JavaScript
Hello!
I need to replace Span tags to div with all the same attributes. ( 'couse it;s not valid construction produced by DNN).
<span id="dnn_ctr831_ContentPane ">
<div id="dnn_ctr831_ModuleConte nt">
<div id="dnn_ctr831_HtmlModule_ HtmlModule _lblConten t" class="Normal">
<img height="445" width="638" src="/Portals/8/how-we-get -4_03.jpg" alt="X" />
</div>
</div>
</span>
Please advise
I need to replace Span tags to div with all the same attributes. ( 'couse it;s not valid construction produced by DNN).
<span id="dnn_ctr831_ContentPane
<div id="dnn_ctr831_ModuleConte
<div id="dnn_ctr831_HtmlModule_
<img height="445" width="638" src="/Portals/8/how-we-get
</div>
</div>
</span>
Please advise
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
(inside the javascript) window.onload=display)
I've included this in the code below
I've included this in the code below
<html>
<head>
<title>Test</title>
<script type="text/javascript">
function display() {
var contents = document.getElementsByTagName('body')[0].innerHTML;
contents = contents.replace(/<span/gi, "<div");
contents = contents.replace(/<\/span/gi, "</div");
document.getElementsByTagName('body')[0].innerHTML = contents;
alert(contents);
}
window.onload=display;
</script>
</head>
<body>
<span id="test">
<p>Hello world</p>
</span>
<span id="test2">
<p>Hello again</p>
</span>
</body>
</html>
ASKER