Solved

WebBrowser delete tag

Posted on 2010-08-30
8
337 Views
Last Modified: 2012-05-10
Hi,

How can i delete tag from webbrowser component?
Or how i can get tag source by tag name?
0
Comment
Question by:lavitz
8 Comments
 
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
0
 
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');
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 33557433
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

Author Comment

by:lavitz
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.
0
 

Author Comment

by:lavitz
ID: 33557438
And by 'tag' i mean html tag i.e <SPAN>
0
 
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);


0
 
LVL 13

Accepted Solution

by:
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
0
 
LVL 2

Expert Comment

by:adlabac
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;
    Begin
      Result:='';
      Start:=Pos ('<',Code);
      While Start>0 do
        Begin
          Stop:=Start+1;
          While (Stop<=Length (Code)) and (Code [Stop]<>'>') do
            Inc (Stop);
          If Stop>Length (Code) then
            Exit;
          Code:=Copy (Code,1,Start-1)+Copy (Code,Stop+1,Length (Code)-Stop);
          Start:=Pos ('<',Code)
        End;
      Result:=Code
    End;

Open in new window

0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delphi exception 7 64
Show Listview image from database (String field) 5 123
DBGrid or StringGrid ? 6 88
Breakpoint doesn't stop in my variable 3 23
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

785 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