Changing title and options in javascript confirm dialog [duplicate] - javascript

This question already has answers here:
Changing the default title of confirm() in JavaScript?
(8 answers)
Closed 9 years ago.
I want to add my project title to a javascript confirm dialog, and want to change "Ok" and "Cancel" to "Yes" and "No". How can I do this?

We can't override the functionality of the JS . But you can show your project name on top by using the trick "nextline(/n)" as i did in my project :)
This is just an trail solution for your satisfaction . :)
confirm("ProjectName \n\n\n\n\ some question goes here ");

If you're talking about confirm function in javascript, well, you can't change its properties. I suggest look into using a custom confirm dialog box e.g. jQuery UI's modal confirmation. You have many options out there and by using custom ones you have a lot of things you can do, you can even change colors of the box if you want. Just an idea :)

Related

How to use javascript to show the list of a datalist? [duplicate]

This question already has answers here:
Programmatically make datalist of input[type=url] appear with JavaScript
(2 answers)
Closed 2 years ago.
I have a datalist. Its list is empty at the beginning. I use javascript to append the options to that list and want to show the list immediately without clicking it manually. I may need to use javascript code to implement this. Could anyone know how to do this? Thanks in advance! By the way, document.getElementById("element").focus(); This doesn't work. It can only move the mouse to the input area but can't show the list. I want to show that list.
We need to create the "append the options to that list" function.
I think we can create that function based on the behavior of the click, and then run it after the page loads.

Changing the "<URL name> says:" header to confirm dialog box [duplicate]

This question already has answers here:
How to edit a JavaScript alert box title?
(10 answers)
Closed 6 years ago.
When using the confirm dialog box in Javascript, the first line is "<URL name> says:" then it is followed by the string specified in the js call.
Is there a way to change that first line?
The confirm box, just like the alert box, is a system object, and not subject to CSS. To do this style of thing you would need to create an HTML element and mimic the confirm() functionality.
What you want is not possible, the url in the confirm window is not customizable. As a solution you could create your own modal box and style it as desired.

In Javascript How can I customize alert window? [duplicate]

This question already has answers here:
Custom alert using Javascript
(6 answers)
Closed 7 years ago.
In a static html page i want to do following actions:
as the url is entered first I want to display the terms and conditions using window.alert("TERMS AND CONDITIONS").
In the dialogue box I want two buttons "agree" and "dont agree". If agree is pressed I want to use window.location.assign("next page url") .And if dis agree is pressed I want to use window.close("","_self")
I'm a total beginner and have minimum knowledge of Javascript.
Thank you in advance.
You can not modifiy the default alert dialog.
But instead, you can use one of the many Dialogs made for jquery and other libraries.
http://www.sitepoint.com/14-jquery-modal-dialog-boxes/
The alert box is a system object, and not subject to CSS. The jQuery UI Modal box does a lot of the work for you Link.
if you want a basic browser graphic u can use
window.confirm("TERM AND CONDITIONS");
that return true or false based on action. For more advaced usage check jquery dialogs boxes (docs https://jqueryui.com/dialog/ ) or bootstrap (docs http://nakupanda.github.io/bootstrap3-dialog/)

Styling suggestions dropdown [duplicate]

This question already has answers here:
How to style the browser's autocomplete dropdown box?
(2 answers)
Closed 9 years ago.
Defaultly, when you input something to text field, you get suggestions with values you entered before. So my question is, is it possible to use CSS to modify appereance of that suggestion dropdown. Or could you please suggest javascript code to recreate its bahavior?
No, it is browser's native implementation. the browser doesn't even add or modify any new DOM element therefore you can not style the dropdown list. I am not 100% sure but it looks like the drop down list is on a different layer on top of the display page. You will need to have a your own Javascript implementation of autocomplete.
By the way to disable this browser behavior, add this to the input element:
autocomplete="off"
Note that not all browser support autocomplete attribute
You can't fiddle with the native browser's autocomplete box, but you can with custom implementations. I'd wager the most popular is this one: http://jqueryui.com/autocomplete/
I should note that the custom implementation won't serve up values the user has entered before unless you are capturing each term the user is entering, and use that list to populate your autocomplete box.

How can I change the title message of an alert box in JavaScript? [duplicate]

This question already has answers here:
How to edit a JavaScript alert box title?
(10 answers)
Closed 3 years ago.
How can I change the title message of an alert box in JavaScript?
This can not be done using javascript. But this can be done using jQuery. May be this url can help u.
http://labs.abeautifulsite.net/projects/js/jquery/alerts/demo/
This cannot be done. The title is browser dependent and you have no control over it. On the other hand you could implement your own alert box using divs and customize it as you like. Here's an example using the jquery dialog plugin.
I am pretty sure this is outside of your control and can not be changed
This earlier question has some good suggestions in the answers : how-to-edit-a-javascript-alert-box-title

Categories