Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>How can i remove site url from top of javascript alert?</p> </blockquote> <p>You can't. The browser adds that so that the user knows that the message isn't from the browser itself.</p> <p>The only thing you can do is stop using <code>alert</code> entirely, and instead use modern techniques for overlaying an element on top of the page. You can write this yourself, or use any of the many "lightbox" libraries out there. Note that doing so changes how you code things a bit, because while <code>alert</code> (and <code>confirm</code> and <code>prompt</code>) bring execution of scripts on the page to a screeching halt while they're on-screen, you can't do that in your own code, so you have to structure your code to continue when it receives the event that the user dismissed the box. Usually the library will give you a callback you can use for that, so for instance this <code>alert</code> code:</p> <pre><code>function foo() { doSomething(); alert("Foo!"); if (x != 42) { doSomethingElse(); } } </code></pre> <p>becomes</p> <pre><code>function foo() { doSomething(); someNiftyLightboxThingy("Foo!", function() { if (x != 42) { doSomethingElse(); } }); } </code></pre> <p>Not hard, you just have to get used to it.</p> <p>You don't <em>have</em> to use a library for this, but doing so lets you not worry about edge cases and may offer you more features. Here's a fairly bare-bones example:</p> <p>HTML:</p> <pre><code>&lt;input type='button' id='btnPopup' value='Click for Pop-Up'&gt; </code></pre> <p>CSS:</p> <pre><code>iframe.shim { width: 100%; height: 100%; position: absolute; left: 0px; top: 0px; z-index: 100; background-color: #fff; opacity: 0.5; /* Standard */ filter: alpha(opacity = 50); /* For IE */ } div.overlay { z-index: 101; border: 1px solid black; background-color: #ecc; position: absolute; left: 100px; top: 100px; } </code></pre> <p>JavaScript:</p> <pre><code>function doVerySimplePopup(text, callback) { var shim, div, parent = document.body; shim = document.createElement('iframe'); shim.className = 'shim'; parent.appendChild(shim); div = document.createElement('div'); div.className = 'overlay'; div.innerHTML = text; parent.appendChild(div); div.onclick = function() { parent.removeChild(div); parent.removeChild(shim); if (typeof callback === "function") { try { callback(); } catch (e) { } } }; } </code></pre> <p><a href="http://jsbin.com/ocobu4/6" rel="nofollow">Live example</a></p> <p>Obviously you'd want to tart that up a bit, and again, this is a bare-bones example, not a complete solution.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload