Board index » delphi » Preventing JavaScript resize in TWebBrowser
Nick Bradbury (TopStyle/FeedDemon)
![]() Delphi Developer |
Nick Bradbury (TopStyle/FeedDemon)
![]() Delphi Developer |
Preventing JavaScript resize in TWebBrowser2004-03-03 03:52:22 AM delphi146 I have a Delphi app which hosts TWebBrowser, and pages which use JavaScript to resize the browser window cause the browser to be resized within my app. I've tried to work around this by trapping OnDocumentComplete and various other events and then forcing the browser to resize to fit its container, but this doesn't always work. Does anyone know a reliable way to prevent JavaScript from resizing TWebBrowser? Thanks, -- Nick Bradbury www.bradsoft.com |
Simon
![]() Delphi Developer |
2004-03-03 04:02:05 AM
Re:Preventing JavaScript resize in TWebBrowserQuoteDoes anyone know a reliable way to prevent JavaScript from resizing HTH, Simon |
Nick Bradbury (TopStyle/FeedDemon)
![]() Delphi Developer |
2004-03-03 04:21:20 AM
Re:Preventing JavaScript resize in TWebBrowserQuote"Simon" writes: -- Nick Bradbury TopStyle/FeedDemon Support |
eshipman
![]() Delphi Developer |
2004-03-03 04:49:14 AM
Re:Preventing JavaScript resize in TWebBrowser
In article <4044e5f5$XXXX@XXXXX.COM>, "Nick Bradbury
\(TopStyle/FeedDemon\)" <XXXX@XXXXX.COM>says... QuoteI have a Delphi app which hosts TWebBrowser, and pages which use JavaScript I have an example posted around somewhere, either on EE or Delphi Pages. Let me find it. Basically, I added an error handler to stop js errors. |
eshipman
![]() Delphi Developer |
2004-03-03 05:03:28 AM
Re:Preventing JavaScript resize in TWebBrowser
In article <XXXX@XXXXX.COM>,
eshipman@yahoo!!!.com says... QuoteIn article <4044e5f5$XXXX@XXXXX.COM>, "Nick Bradbury Memo1.Lines.Text = function stopError() { return true; } window.onerror = stopError; ************************************************************************ procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject; const pDisp: IDispatch; var URL: OleVariant); var ovScript: OleVariant; begin // Only loading the first script, The error handler only // needs to be added to the first one. ovScript := WebBrowser1.OleObject.Document.all.tags('SCRIPT').item(0); Memo1.Lines.Add(ovScript.text); ovScript.Text := Memo1.Lines.Text; end; Looks to me like you should be able to parse the js in ovScript to see if it contains the resize code and get rid of it. I would suggest adding the error hadnler as well. |
Nick Bradbury (TopStyle/FeedDemon)
![]() Delphi Developer |
2004-03-04 03:58:31 AM
Re:Preventing JavaScript resize in TWebBrowser
Now why didn't I think of that ?! Thanks for sharing this - it might save
me a lot of headaches with JS errors :) -- Nick Bradbury TopStyle/FeedDemon "eshipman" <eshipman@yahoo!!!.com>writes QuoteHere it is: |