WebBrowser delete tag

Posted on 2010-08-30
Last Modified: 2012-05-10

How can i delete tag from webbrowser component?
Or how i can get tag source by tag name?
Question by:lavitz
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 37

Expert Comment

by:Geert Gruwez
ID: 33557375
you can hide it be recreating a new component
but it takes a special function call

is it something like that your are looking for ?

you can't hide it from the standard component
LVL 37

Expert Comment

by:Geert Gruwez
ID: 33557407
in the new package you need to call this procedure from DesignIntf

procedure UnlistPublishedProperty(ComponentClass: TClass; const PropertyName: string);

you do this after the call to registercomponent.

UnlistPublishedProperty(TWebBrowser, 'TAG');
LVL 37

Expert Comment

by:Geert Gruwez
ID: 33557433
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 33557434
Iam using webbrowser for mail editing. In edit mode, source mail have additional tags and scripts that are using only when editing. Before mail save iis done i need to remove these tags end scripts so i search for safe solution to remove them.

Author Comment

ID: 33557438
And by 'tag' i mean html tag i.e <SPAN>
LVL 37

Expert Comment

by:Geert Gruwez
ID: 33557468
ah it's in the source code of the html

if you have the source, then you can use posex on that if you have a unique way of distinguishing the tags

<TAG ID=1234 ...> </TAG>

n := PosEx('<TAG ID=1234', html.sourcetext);
m := PosEx('</TAG>', html.sourcetext, n);
Delete(Html.sourcetext, n, m-n+5);

LVL 13

Accepted Solution

aflarin earned 500 total points
ID: 33557523
if your span tag has id or name attribute like this:

<span id="tag_name"... or <span name="tag_name"...

you can use this code:

  WebBrowser1.OleObject.Document.all.Item( 'tag_name' ).removeNode( True );

if no - please show all html code, because it need to find where span tag is located

Expert Comment

ID: 33557737
If you want to remove all tags in a message you can use this function. Just pass the complete message as a string and it will return the string with all tags removed. If your message is not in one string, simply repeat the procedure for each one.
Function RemoveTags (Code:string) : string;
  Var Start, Stop : integer;
      Start:=Pos ('<',Code);
      While Start>0 do
          While (Stop<=Length (Code)) and (Code [Stop]<>'>') do
            Inc (Stop);
          If Stop>Length (Code) then
          Code:=Copy (Code,1,Start-1)+Copy (Code,Stop+1,Length (Code)-Stop);
          Start:=Pos ('<',Code)

Open in new window


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question