How to create and apply CSS to javascript Alert - javascript

Please tell me, how to apply CSS on javascript Alert.
Thanks

You cannot. alert() simply shows a native message box, so it'll look however the OS makes it look.
In general, you shouldn't be using alert boxes because they are annoying and they block the entire browser.* You could always create a fake alert box with JavaScript that achieves the same effect. You could then style it however you want with normal CSS. If you use jQuery, there's SimpleModal (demos).
* Modern browsers tend to only block the window that spawned the alert, but they're still annoying and you still shouldn't use them. :)

It is not possible, or else people will use it to phish.

you might want to check jConfirm (jQuery plugin)
http://abeautifulsite.net/2008/12/jquery-alert-dialogs/

No you can't do that. I would suggest you either let it be, or use a modal window. You can also try using modal/dialog plugins e.g. http://docs.jquery.com/UI/Dialog

You can use the sweet alert library of js
official website
github
You can also customize the alerts with simple CSS.

Related

How can I disable firebug in my webpage?

How can I disable firebug using Javascript? I want to do this to hide the workings of my webpage from visitors. Is there any option to do this?
You can't. The best you can do is obfuscate your JavaScript.
Actually scratch that. The best you can do is move all the security-critical code to the server. You should be doing that anyway.
You can't do it. Check this stackoverflow question on different methods others have adopted as a work around of sorts
As Amadan said, you can't disable particular source-viewers.
But you can use a hack. It works only with viewers, that add them selves to the DOM. You just have to delete specified node. Did a look-around with Firebug Lite for Chrome.
DON'T use this approach, only for fun :)

is it possible to add two values for the mouseOver command?

i want two things to happen when i move the mouse over an image, is there a way to write the code that way?
<a href="http://google.com/" target="_new"
onMouseOver="MM_swapImage('301','','/w/w-1.gif',1)"
onMouseOut="MM_swapImgRestore()">
this is the original code for general rollover images in dreamweaver, but i want to add more to onMouseOut= and Over= like onMouseOut="MM_swapImgRestore()";"some command" or how can i write this? im using javascript
i appreciate any help!
The onMouse* properties usage is deprecated in modern browsers.
You should use addEventListener or something corresponding instead.
These 'listeners'-based implementations allow to add as much event-handlers as you want to any event.
I don't remember exact cross-browser syntax for this, but you can see it inside the the source code of any popular JS framework (like jQuery or Prototype or MooTools), or just use this framework.
Ofcourse it's possible to do something like:
onMouseOver="func1();func2();func3();"
But it's a bad-practice because this approach is incompatible with much of third-party JavaScript libraries you probably will use.
Have it call a function that calls both functions.
EDIT It's even easier. Just do
onMouseOver="func1(); func2()"
Using the idea of Vadim, you can do this:
// Others (Chrome, Firefox, etc)
document.addEventListener("mouseover",function(){thingone(); thingtwo();},false);
// IE
document.attachEvent("onmouseover",function(){thingone(); thingtwo();});
PS: Shall I quote cdhowie too, for the function names?

Can javascript capture image download times in the client?

With javascript event timers, you can relatively easily determine how long it too for the page to render in the browser, especially when using tools like Jiffy. However, is it possible to capture more granular events such as individual image/object download times using javascript in the page? I am fairly sure this is not possible, but wanted to confirm with the javascript guru's of SO.
Thank you in advance.
Sadly, unless you load the images using the javascript image object manually instead of in the markup, I don't believe this is possible. that's why you usually see this functionality in things like firefox plugins
You could look at the Net tab in Firebug. I don't know if it can give you same information via Firebug Lite in other browsers or not.
If what you want to time can be put into an event that has a callback, you can check the time before and after. So anything you do with Ajax you can time. What exactly are you trying to time? Can you be more specific?
I'm not totally familiar with this jQuery plugin, but it may be of help to you:
http://plugins.jquery.com/project/timers

PopupWindow in jQuery

I am in need of a popupwindow with the option of a radio button. I have tested with Impromtu. Is any easy made Popupwindow plugin available?
My plugin should work in Internet Explorer, Mozilla and Google Chrome. What would some sample code be?
jqModal is great and easy-to-use for building Modal Popups and the like.
If you want a tutorial on how to build one yourself without jQuery, check out this tutorial.
Check out Thickbox! You can use a div or so on your page as content (see inline content demo).
Here's a list of lightbox like plugins depending on your need:
http://www.fortysomething.ca/mt/etc/archives/006978.php
If you're not absolutely bent on using jQuery, there is another library available that uses the Prototype library that is rather handy. The popup windows are very easy to implement, and the modal dialog boxes are even easier.
On a side note, I have used thickbox before and was rather impressed, but the URL parsing structure that it uses were kind of limiting me for what I needed to do (I was using a ComponentArt object that didn't use anchors).
Anyway, definitely check out this tool. It's probably more than you need, but who knows maybe you'll get inspired to find other uses for it. It's a pretty fun tool:
http://prototype-window.xilinus.com/documentation.html
FaceBox is another option to check out.

Changing the default title of confirm() in JavaScript?

Is it possible to modify the title of the message box the confirm() function opens in JavaScript?
I could create a modal popup box, but I would like to do this as minimalistic as possible.
I would like to do something like this:
confirm("This is the content of the message box", "Modified title");
The default title in Internet Explorer is "Windows Internet Explorer" and in Firefox it's "[JavaScript-program]." Not very informative. Though I can understand from a browser security stand point that you shouldn't be able to do this.
This is not possible, as you say, from a security stand point. The only way you could simulate it, is by creating a modeless dialog window.
There are many third-party javascript-plugins that you could use to fake this effect so you do not have to write all that code.
YES YOU CAN do it!! It's a little tricky way ; ) (it almost works on ios)
var iframe = document.createElement("IFRAME");
iframe.setAttribute("src", 'data:text/plain,');
document.documentElement.appendChild(iframe);
if(window.frames[0].window.confirm("Are you sure?")){
// what to do if answer "YES"
}else{
// what to do if answer "NO"
}
Enjoy it!
Not possible. You can however use a third party javascript library that emulates a popup window, and it will probably look better as well and be less intrusive.
You can always use a hidden div and use javascript to "popup" the div and have buttons that are like yes and or no. Pretty easy stuff to do.
You can't unfortunately. The only way is to simulate this with a window.open call.
Don't use the confirm() dialog then... easy to use a custom dialog from prototype/scriptaculous, YUI, jQuery ... there's plenty out there.
I know this is not possible for alert(), so I guess it is not possible for confirm either. Reason is security: it is not allowed for you to change it so you wouldn't present yourself as some system process or something.
Yes, this is impossible to modify the title of it. If you still want to have your own title, you can try to use other pop-up windows instead.

Categories

Resources