删除页面上的空标签 [英] Remove Empty Tags on page
问题描述
大家好,
我正在编写一个理论上很简单的脚本,但是我无法完成这项工作。
完全正常工作。我正在处理由.NET发出的页面,在标记中留下空的
标记。我需要一个javascript解决方案,以便在页面加载后进行干净运行。
.NET将留下任何嵌套标签的组合。这是下面的
示例。即使< spantags不是空的,因为它们包含
< emtags,它们也需要被移除。
< p>
< span>< em>< / em>< / span>
< span>< em>< / em>< / span>
< span>< em>< / em>< / span>
< / p>
这是我到目前为止所做的一个简单的测试页面。它确实删除了一些标签,但总是留下一些空标签...
http://mysite.verizon.net/res8xvny/removeTags.html
任何关于最佳接近方式的想法这个?
David
Hi All,
I am working on a script that is theoreticaly simple but I can not get it to
work completely. I am dealing with a page spit out by .NET that leaves empty
tags in the markup. I need a javascript solution to go behind and do a clean
up after the page loads.
The .NET will leave behind any combination of nested tags. Here is an
example below. Even though the <spantags are not empty, as they contain
<emtags they also need to be removed.
<p>
<span><em></em></span>
<span><em></em></span>
<span><em></em></span>
</p>
Here is a simple test page of what I have done so far. It does remove some
of the tags but always leaves behind some empty tags...
http://mysite.verizon.net/res8xvny/removeTags.html
Any ideas of the best way to approach this?
David
推荐答案
大卫 < no ** @non.comwrote in message
news:HeA_j.8105
"David" <no**@none.comwrote in message
news:HeA_j.8105
9H6.7786@trnddc04 ...
9H6.7786@trnddc04...
大家好,
我正在编写一个理论上很简单的脚本,但我无法得到它
上班完全。我正在处理一个由.NET吐出的页面,它在标记中留下了
空标记。我需要一个javascript解决方案,以便在页面加载后进行清理。
David
Hi All,
I am working on a script that is theoreticaly simple but I can not get it
to work completely. I am dealing with a page spit out by .NET that leaves
empty tags in the markup. I need a javascript solution to go behind and do
a clean up after the page loads.
David
对于任何查看页面的内容,您将看到脚本仅通过一组标签循环
...
var tagArray = [" em"," span"," p"," a"," li"," ul"];
使用所有标签.. el = document。 getElementsByTagName(" *")将是
首选方法,但我发现自己需要几个循环和几个
node.parentNode.removeChild()'s和它仍然没有正常工作。
David
For any that look at the page you will see the script is only looping
through a certain set of tags...
var tagArray = ["em", "span", "p", "a", "li", "ul"];
Using all tags.. el=document.getElementsByTagName("*") would be the
preferred method but I found myself needing several loops and several
node.parentNode.removeChild()''s and it still didn''t work correctly.
David
在文章< HeA_j.8105
In article <HeA_j.8105
>
这篇关于删除页面上的空标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!