I have an application that uses WebBrowser control to navigate from page to page, on some pages I get a leaving popup asking me if that's what I want to do.. this stops the whole further execution until I press "Leave" or "Stay".. How can I disable them?
What I've tried so far were these actions:
a) setting window.onbeforeunload = null;
b) setting alert, confirm, prompt to an empty function
c) settin suppressErrorMessages to true
but even so, I still get the nasty message in the end.
I mostly relied on this answer:
How to update DOM content inside WebBrowser Control in C#?
But so far without a success.
The alerts seem to be jQuery alerts because they have custom texts (instead of OK Cancel, they have Stay Leave)..
Any help hugely appreciated!!
The webbrowser control uses IE internally and IE has a prompt if you've filled out a form asking you if you really want to leave the page (thereby losing the content you've filled out) perhaps that's what you're seeing?
i'm just shooting from the hip here but you could try clearing all inputs before navigating.
I have a aspx page. By default, when the page loads the focus is on first textbox. I want to remove the focus to nothing. I am developing this website for a mobile device.
We have come to this nothing conclusion due to some cross browser restrictions we faced with IE.
Page.Focus(); in the init is not working and I don't want to set up the focus to anything.
This information is all I have. Hope it is sufficient for possible resolution.
I will appreciate your feedback and time spend on this query...
An alternative can be to create a hidden control and move the focus to that control
If you're able to use jQuery why don't you do
$('#idOfInputWhichKeepsOnGettingFocus').blur();
If not, create a new first field
<input id="youCannotSeeMe" style="position:absolute; left:9001px;" />
This works:
Page.SetFocus(this);
There's no easy way to explain this but, I have a website, that links to a online game I've made using asp C#. The website has a link to the game so when the user clicks the link on the site, my game pops up! Simples...
But I want it to pop up in a new Window! but not a browser window... Just... A Window :s
for Example, if you go on www.dofutoshiki.com and click on the "Play Futoshiki in our online player" link, it opens a new window with, just the game. No browser functionality.
I was wondering if anybody out there could shed some light on the subject...
Ive Tried:
Click me!
but it just opens a new tab in the browser!
Thanks!
Alex
If I get this right, you actually want a browser window but without the chrome/UI.
For this, you need to use window.open() (javascript) rather than a target attribute.
http://www.pageresource.com/jscript/jwinopen.htm will help you.
You have to open the new window by using javascript and disabling the unwanted functionality by passing arguments.
You will probably need some javascript for this. What you need to look in to is the
'window.open(...)' function.
Here are a few examples.
And here you can play around with it.
Use javascript Window.open method
Click me!
<script>
function openGame(){
window.open(blahblah.aspx,'Play Game','width=900,height=790,scrollbars=yes,dependent=yes,toolbar=no,location=no,status=no,directories=n o,menubar=no,status=no,resizable=yes');
}
</script>
You can use Jquery popup window plugin it is easy to use and more flexible also.
http://swip.codylindley.com/popupWindowDemo.html
On site you are referring to, browser window is opened. It's configured so that it does not have toolbar, status bar, menu bar, etc.
You can take a look at window opening code in HTML source of the page you are referring to:
<a onClick="window.open(this,'playsample','width=900,height=790,scrollbars=yes,dependent=yes,toolbar=no,location=no,status=no,directories=no,menubar=no,status=no,resizable=yes');return false;">
Is javascript an option?
With javascript it would be something like this:
<a href="#" onclick="window.open('blahblah.aspx', 'game','status=0,toolbar=0,width:400,height:300');" > Click here for the game! </a>
Use this
Click me!
Or even better, put the onclick code in a function of your own so you can reuse it.
I have a situation that I am stuck with, and hoping someone can help. I am building a .NET/C# web application in which I have a tabbed panel layout, and when the user clicks on each of the tabs the display panel is updated using javascript to hide and show some divs. None of these clicks cause postback, it is all client-side, so I can't use viewstate or session.
What I want to do is somehow remember which panel was last visible when the page is refreshed, yet without posting back to the server I am unsure how to do this. I have tried a hidden field but obviously its value is reset every time because the form is never submitted. I do know that I can achieve this using cookies but its a little annoying to implement for such a (seemingly) trivial operation ... but maybe this is the only way?
Does anyone have any more elegant solution to this problem?
Using a function like this to show and hide tabs):
function makeCurrent(tab) {
if (tab.title == 'Manage orders') {
document.getElementById('panelOrders').style.display = "block";
// Hide others
document.getElementById('panelAccounts').style.display = "none";
document.getElementById('panelProducts').style.display = "none";
document.getElementById('panelSettings').style.display = "none";
// Remember last viewed panel
document.getElementById('hdnCurrentlyViewing').value = "orders";
}
The panels are just divs with style.display controlling their visibility. Not sure if its useful to post HTML code because its fairly self explanatory ...?
You can make this happen without a postback is to make an AJAX call from Javascript where you tell your server what the current panel is as you switch it.
I prefer using a framework like JQuery or Prototype to help make these AJAX calls myself.
I think Hidden field will be the best option. have you tried ASP:HiddenField? It can be accessed across postbacks.
But if you still have some reservations with postbacks and hiddenfield you can also use cookies from JS http://techpatterns.com/downloads/javascript_cookies.php this is helper lib for cookies manipulation within JS.
Regards.
I have an ASP.NET application that also uses jQuery for modal pop-ups. If I put an ASP button (or image button) within the DIV for the jQuery modal, the "OnClick" event does not fire.
How can I fix this?
When you create the dialog, you need to move it a bit for ASP.Net, like this:
$(".class").dialog({
//options
}).parent().appendTo("form");
By default the .dialog() moves the content to just before </body> which most importantly is outside the <form></form>, so elements within it won't be included in the POST (or GET) to the server. If you manually move it like I have above, it'll resolve this issue.
By default, jQuery places the modal OUTSIDE of the asp.net <form> element.
You can easily append it to the form like:
$("#your-modal").parent().appendTo("form:first");
And this should fix your problems. It's a common problem with jQuery/ASP.NET.
Enjoy