window.location.indexOf not working in Javascript

window.location is an accessor property, and getting its value gives you an object, not a string, and so it doesn’t have an indexOf function. (It’s perfectly understandable that people sometimes think it’s a string, since when you set its value, the accessor property’s setter accepts a string; that is, window.location = “some url”; actually works. … Read more

JavaFX Alerts and their size

I have made the following workaround: Alert alert = new Alert(AlertType.INFORMATION, “Content here”, ButtonType.OK); alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); alert.show(); So the window will resize automatically according to the content.

Change button color in AlertDialog

Here is how I did. AlertDialog.Builder customBuilder = new AlertDialog.Builder(new ContextThemeWrapper(this,android.R.style.Theme_Dialog)); customBuilder.setTitle(R.string.popup_error_title); customBuilder.setNegativeButton(“Exit application”, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { MyActivity.this.finish(); } }); AlertDialog dialog = customBuilder.create(); dialog.show(); Button b = dialog.getButton(DialogInterface.BUTTON_NEGATIVE); if(b != null) { b.setBackgroundDrawable(getResources().getDrawable(R.drawable.my_button)); } I find the drawable here

How to override the alert function with a userscript?

Update: For modern versions of Tampermonkey, Violentmonkey, Greasemonkey (but strongly recommended to avoid GM 4+): You can intercept alert() in most cases by using @run-at document-start. For example, load this script and then visit the test page: // ==UserScript== // @name _Overwrite Alert // @match *://output.jsbin.com/* // @grant none // @run-at document-start // ==/UserScript== var alrtScope; … Read more