SpicIE toolbar, SHDocVw.IWebBrowser2 execScript problem? - c#

I'm developing an addon for IE8+.
Main function:
- when I click the toolbar, it will display a box inside every single page, ex: google.com, bing.com, codeproject.com... by using execScript to execute jQuery.
Therefore, what Im doing is run javascript in the current page.
Everything has done except when that page perform an Pop-up, it doesnt work anymore.
I click the toolbar, nothing happen, but when I look at the pop-up, surprise! has the box which im trying to display. So, I think the current tab and the popup of its is running the same process.
I have change registry key TabProcGrowth to 20, to make sure every single tab run by its own process, but maybe it not work with popup.
sr for my bad english, any suggestion is welcome.
Thanks in advance.
update:
I have changed the way to develop my addon, so I change my question, too. (But any suggestion for the 1st question still very useful for me).
My new question still mention the "execScript" problem.
HOW to execute javascript with every individual tab of IE browser with TabProcGrowth = 0. I need this value set to 0 because I have the timer to request to the server every interval1 (ex: 60s). So if there are more than one processes of IE, the addon will send multi request to server at the sametime.
In my situation now, I set TabProcGrowth to 0. Open IE, open some tabs. Click the toolbar at the newest tab, it works, ofcourse!. But when I click toolbar at the old one, nothing happen. The script still be execute but it takes effect on the newest tab.
It's the big problem for me, resolve this problem, you guys save my life.

Related

Is it possible to debug in multiple browsers at the same time when I hit F5 in VS 2010?

I just want to test my code in multiple browsers at the same time, instead of right clicking on the aspx then clicking browse with... It's kinda frustrating me since my boss wants me to be fast always.
and please don't suggest copying the url then pasting it to the browser, because I already know that...
It is indeed possible, here is a link to a simple guide that was designed for VS 2013 but should track up to 2017, find it here.
Here are the important bits:
When you select the “Browse With…” option, following dialog will
appear, and you can see all the list of browser along with the browser
which marked as “(Default)”.
Now, there can be more than one default browser, and same has been
written in the dialog control as well – “Browsers (Select one or
more):” . So, select all the browser in which you want run the
application together, and click on “Set as Default”. That’s all. Now
if you click on “Browse” button in the same dialog control, you will
find your web application starts on all the selected browser same
time.
This presents you with a 'multiple browsers' option for debugging.
Note:
As per Raniels comment below:
visual studio 2010, I just pressed crtl + click browsers that I want
to set as default.

c# click button web browser visual studio

I hit another bump
webBrowser1.Document.GetElementById("submit_button").InvokeMember("click");
When it runs the button moves in the browser but it still do not work, I have to click the button twice that runs the code then it works
I tried using
webBrowser1.Document.GetElementById("submit_button").Focus();
webBrowser1.Document.GetElementById("submit_button").InvokeMember("click");
still not working
I think I need some kind of double click instead of only clicking once
As long as you are sure you have the proper ID for the element then the issue may just be that the "click" member is being invoked before the page has loaded.
Try this to be sure the document is loaded:
if (webBrowser1.ReadyState==WebBrowserReadyState.Complete)
webBrowser1.Document.GetElementById("submit_button").InvokeMember("click");
If it is a double click that you need, possibly try invoking the click twice with a sleep in between of a couple seconds? It is not the cleanest method though..

Disable prompts in Windows Forms Webbrowser

I have a C# application which uses a System.Windows.Forms.WebBrowser.
The problem is: i'd like the user to navigate smoothly in my application, without prompts, without javascript windows popping up, without security prompts. Even if this requires some contents to be unavailable.
I just want to have one window (always one window, if a receive a new window event, i redirect it to the single window).
How can i do this?
I tried to use this.browser.ScriptErrorsSuppressed = true but i doesnt seem to work.
For example, if i test it on a browser page which performs text validation, i still receive a popup window saying that my text is invalid.
Thank you!
I've found a solution somewhere else, since it wasn't available here.
Here it is: http://www.codeproject.com/Articles/31163/Suppressing-Hosted-WebBrowser-Control-Dialogs
Basically, you have to hook the WM_INITDIALOG message.
It works wonders here.

Difference between calling __doPostBack and Click Event of an asp button

I am using __doPostback of a button control and it will take some time to complete the db operations. I am using it in an update panel and I am getting an issue from IE that it will say
Stop running this script.
May I know what is the issue ?
I think it may be due to __doPostBack. Previously it is direclty calling the Click Event. Thanks in advance.
Check your User Agent string. This same thing happened to me one time and I realized it was because I was testing out some pages as "googlebot". The JavaScript that is generated depends on knowing what the user agent is.
From http://support.mozilla.com/tiki-view_forum_thread.php?locale=tr&comments_parentId=160492&forumId=1:
To reset your user agent string type about:config into the location
bar and press enter. This brings up a list of preferences. Enter
general.useragent into the filter box, this should show a few
preferences (probably 4 of them). If any have the status user set,
right-click on the preference and choose Reset
Avoiding the 'Script taking too long' (all browsers have some form or another of this) message in browsers is relatively simple. You just have to make sure the browser knows you have not created an endless loop or recursion. And the easiest way to do is is to just give the browser a breather in between long running tasks.
have a look at this solution
http://www.picnet.com.au/blogs/Guido/post/2010/03/04/How-to-prevent-Stop-running-this-script-message-in-browsers

How do i close all open windows from my C# program?

Hi i have a windows application where i show a webbrowser, i have a button that removes the browser (its a preview) and goes to another "view" in my application (another tab). My problem is that my users are getting advanced, they build HTML with links (and its ok) but the links may spawn new browser windows (IExplorer), and my button needs to close these windows, but how?
I have made some code to traverse all eht windows that ends with "Windows Internet Explorer", ahd it all seems to work - but how do i close them? I am trying to do it like this:
SendMessage((int)hWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
It seems to work, but the browser pops up a dialog asking me if i want to close the tab of all the tabs...how to work around/solve this?
Cheers,
walking over all top level iE windows and closing them is a bad idea, unless you are guaranteed users can't launch ie and browse the Internet on their own. Otherwise, you might actually lose user data (say an email or a blog post the user has been working on in the last half an hour)
You can't easily work around that dialog without modifying the per-user IE settings. Your other option is to look for that dialog and click the yes button, but that would be fragile and is not guaranteed to continue working if the user upgrades to IE9.
You could potentially prevent opening links in new window by listening to BeforeNavigate event and allowing only navigations that are guaranteed to happen in your control. However, there are scenarios where IE might still decide to open new window.

Categories