Javascript alert in chrome - javascript

I have an alert box, and when I run that code in Firefox, no matter what program I have over firefox, firefox appears with the pop-up automatically over other programs open.
This however, does not work in Chrome.
What gives? Would this be a perference change or this there a line of code that says focus on this window.

I used
window.blur();
window.focus();
and that fixed my problem :)

The implementation of alert is browser specific. Unfortunately there is not line of javascript code to change this.

If you want to have customizable (and working the same in every browser) alert window, use jquery UI.
Note: It will be over the actual page, not over the (other) window.

Related

Why am I not getting "Prevent this page from creating additional dialogs" as part of prompt window in Google Chrome?

When run the same on Microsoft edge I am able to see it.
What do I need to change in the settings of Chrome browser?enter image description here
This is my code:
alert("Hello from the JS file");
var age;
var ageroot;
age=prompt("Enter your age");
The issue has been mentioned here: https://productforums.google.com/forum/#!topic/chrome/drS39waj6ik;context-place=topicsearchin/chrome/Prevent$20this$20page$20from$20creating$20additional$20dialogs
And a bug is reported for the same: https://bugs.chromium.org/p/chromium/issues/detail?id=721138
Alert and Prompt boxes have native implementation on every browser, and are not customizable by using JavaScript or CSS.
So, Chrome doesn't have this checkbox in its implementation, while Edge has it. Also, it is completely in the hand of the browser to prevent such boxes in future.

Close current Tab using javascript for multiple browsers(Chrome,IE,Firefox)

I have Exit button in my page, when ever i clicked on that button,current browser tab should be closed.I wrote below code this is working in IE browser only but it needs to work in Chrome and Firefox.
Please help me.
Code:
window.top.close();
You can't do that in other browsers. If you check the console you will see:
Scripts may close only the windows that were opened by it

Javascript and jquery work with IE

My html page cannot work in IE browser. If I turn F12 developer tools on, it starts to work. My page can work with chrome. I guess it is caused by jquery and javascript. Can anyone know how to make it work? Thanks
IE crashes your script if you're using console.log anywhere inside it. Developer tools adds the console functionality - therefor it works if you open it. Remove the console.log and it should start working just fine.
Chrome/Firefox support this by default, thats why it works there no problem.
you're probably using console.log() in your code somewhere. In IE console object doesn't exist unless the dev tools window is active.

javascript- window.open in safari and chrome in body?

I am adding the following javascript at runtime to open a new browser window. I know window.open is available in javascript. But it doesn't work for safari and chrome. Is there any other trick or hooking technique to achieve this.
string script= "window.open('http://www.w3schools.com','_blank','toolbar=yes,location=yes,directories=no,status=1,menubar=yes,scrollbars=yes,resizable=no,copyhistory=yes,left=20,top=20,width=600,height=550');";
ScriptManager.RegisterStartupScript(this, this.GetType(), "newWindowScript", script, true);
Thanks
window.open() most certainly works in Safari and Chrome, I used it today! The demos on the w3Schools site work in Chrome
Try moving the code into a standard in-page <script> block (obviously with the .net stuff removed) to test and see if you get any errors in the console.
It could be that one of the features you are passing as the 3rd argument to .open() is breaking things (like the copyhistory feature - I never saw that before, and it isn't listed in the available options on the w3Schools site)? I have noticed that Chrome tends to ignore the width and open it to whatever size it wants to...
This is because of the popup blocker in the browser. You can use Ajax Modal Popup window instead of Window.Open
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/ModalPopup/ModalPopup.aspx
Another option is Jquery popup
http://yensdesign.com/2008/09/how-to-create-a-stunning-and-smooth-popup-using-jquery/
if you still need to use Window.Open then please refer this
Bypass popup blocker on window.open when JQuery event.preventDefault() is set

Window.open opening tab instead of popup in Opera?

I'm simply opening a popup from JavaScript with the settings you can see in the code. Works fine in Firefox. In Opera it's opening it in a new tab instead. Why?
Here's a JSFiddle:
http://jsfiddle.net/hafWs/3/
The number of parameters doesn't seem to make a difference. Either work in Firefox and IE8. (Don't have IE9 or Chrome to test right now.)
I tried googling... can't find anything. I don't even see anything here that mentions it, yet it's clearly working in their examples: http://www.quirksmode.org/js/popup.html
Thank you for any help.
There is problem with spaces in options param:
window.showPopup = function(){
window.open(
'http://placekitten.com/600/500',
'thePopup',
'width=600,height=500' /* <------- Look, no spaces and works */
);
}
It is still a tab, but with different dimensions. So, it looks kinda as popup.
This is controlled by the browser itself (preferences) and cannot be changed from JavaScript.
NOTE: I've seen some posts that say you can determine whether the window opens in a tab or as a new window based on the parameters that you pass the window.open function. I have never seen this work consistently.

Categories