handling ctrl + key event in IE browser - apache-flex

I'm using hotkeys (Ctrl+key) in my flex application. getting problem when my app is running in IE.
when I press Ctrl+D, im getting 'Add a Favorite' window of IE.
How should I override the default behaviour of the browser? if possible, give me some example.

In your event handler, try
event.returnValue = false;
See this SO thread: event.preventDefault() function not working in IE

Related

Click() method does not return after clicking a link

I have a Web Element (a link) that is correctly found on my page.
<a onclick="javascript:doPostDMS('en-us'); return false;" id="btnPentana" title="Post To DMS" class="shelf-button lnkPostToDMS" href="javascript:__doPostBack('btnPentana','')"></a>
The problem I have is when I execute the click, the button is clicked, a new browser window is opened (this tells me I did actually click), but the click method doesn't return and the test hangs.
With the following code:
Console.WriteLine("Before");
element.Click();
Console.WriteLine("After");
I see the Before statement written to the console.
I see the new window open (a result of clicking the link).
I do Not see the "After".
I'm using Selenium DotNet, 2.29.1
I've tried this using both the Chrome, and Firefox browsers.
The only thing I can think to try is to add a time out feature for/to click and then catch the error. I know click can have issues.

Postback page minimized the browser - Selenium WebDriver

I have a web page that have few dropdowns and when the dropdown item changed it refresh the page and reloads.
so now i am writing script against that page and i have noticed that whenever my scripts select the text from the dropdown my browser get minimized.
my questions, is there any setting to make sure my browser is maximized while running the script?
Here is the code that SelectText from the dropdown:
public void SelectText(By locator, string txt)
{
IWebElement element = driver.FindElement(locator);
SelectElement selectelement = new SelectElement(element);
selectelement.SelectByText(txt);
}
I am using
IE 8
Selenium 2 WebDriver
C#
I strongly suspect that the browser is actually being dropped to the bottom of the Z-order, not minimized. That is to say, it's being pushed to the bottom of the stack of open windows on your desktop. If you have other applications running, and they're running maximized, it can appear as though IE has been minimized, but it really isn't. There are certain actions that are known to cause IE to behave this way, but no one has been able to figure out why yet.
Maximizing the IE window won't solve the problem. Nevertheless, you can maximize the IE window using
// WARNING! Untested code written from memory
// without the benefit of an IDE. Not guaranteed
// to be syntactically correct.
driver.Manage().Window.Maximize();

Disabling Submit Button in ASP.NET 3.5 Application with JavaScript breaks BlackBerry submission

The following code is being used to disable a Submit button once it has been clicked. This works great on desktop browsers and most BlackBerry mobile browsers.
Submit.Attributes.Add("onclick", "javascript:this.disabled=true;" +
ClientScript.GetPostBackEventReference(Submit, null));
Unfortunately, when using a BlackBerry Storm clicking the submit button causes the device to just reload the page. If I remove this code the Storm browser submits the page just fine. I need to disable the button when the browser is capable of doing so but do not want to affect browsers that are not JavaScript capable.
I realize I could add the jQuery framework and only attach the event client side, but am trying to look for the simplest fix (read least intrusive) as this is a legacy application. Any suggestions?
I believe you can do it this way - I haven't done this in a long time and some of the HttpCapabilities API has been tagged as obsolete, but in general you can detect if the browser supports javascript by doing this:
var myBrowserCaps = Request.Browser;
if (((HttpCapabilitiesBase)myBrowserCaps).EcmaScriptVersion.Major > 1)
{
// Browser supports javascript
Submit.Attributes.Add("onclick", "javascript:this.disabled=true;" +
ClientScript.GetPostBackEventReference(Submit, null));
}

Focus is not coming in javascript

I have a button in aspx. In its onclientclick I called a javascript function which is written in JScript.js.
Following is my javascript:
function ChangeBG()
{
alert("hi");
}
I called this above function in button click. I had put breakpoint in javascript. But onclicking on button, alert is coming, but control is not going to breakpoint. What may be the reason for this? I am running in Internet browser. What change i can make to bring the focus to breakpoint. Can anybody help?
Before alert("hi"); put the stmt debugger;
ChangeBG()
{
debugger;
alert("hi");
}
Your control will come to debug when you are in debug mode. This problem occurs when javascript is in a separate js file.
Also do this to enable debugging in your IE browser
Go to
Tool-->Internet Options-->Advanced
Uncheck - Disable script debugging ( Internet Explorer )

Default Form Button in FireFox

I am building a server control that will search our db and return results. The server control is contains an ASP:Panel. I have set the default button on the panel equal to my button id and have set the form default button equal to my button id.
On the Panel:
MyPanel.DefaultButton = SearchButton.ID
On the Control:
Me.Page.Form.DefaultButton = SearchButton.UniqueID
Works fine in IE & Safari I can type a search term and hit the enter key and it searches fine. If I do it in Firefox I get an alert box saying "Object reference not set to an instance of an a object.
Anyone run across this before?
Is SearchButton a LinkButton? If so, the javascript that is written to the browser doesn't work properly.
Here is a good blog post explaining the issue and how to solve it:
Using Panel.DefaultButton property with LinkButton control in ASP.NET
Ends up this resolved my issue:
SearchButton.UseSubmitBehavior = False
I might be wrong and this might not make a difference but have you tried:
Me.Page.Form.DefaultButton = SearchButton.ID
instead of
Me.Page.Form.DefaultButton = SearchButton.UniqueID

Resources