#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    11
    Rep Power
    0

    Chrome doesn't show my message in alert box


    When I have JS popup an alert box in FF it shows the msg I created. When using Chrome all it says is "The page at localhost says OK" Is this a bug in Chrome or is their a different way of getting it to display my msg?
    Thanks
    Paulk
  2. #2
  3. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,008
    Rep Power
    2791
    I have a car. When I turn the key in the ignition the engine does not start. What is wrong with it?

    Going to need a tad more information than what you have provided. Post your code and use [highlight=Javascript[color=black]][/color] CODE [/highlight].
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    11
    Rep Power
    0
    hmmm.. Just about any old code would do. I copied this one from w3schools. The problem is when I run this script in FF I get a proper alert box. When I run it in Chrome I dont. If I could upload a jpg showing yo Chrome's alert box I would. but your forum doesn't allow that. Maybe you could try it in Chrome yourself and see if you get the results I got.
    Thanks

    Javascript Code:
      function myFunction()
    {
    alert("I am an alert box!");
    }
    </script>
    .

    The same thing is true of an Confirm box. Works in FF not in Chrome. haven't tried other browsers. Point to note. Popups are blocked in both browsers.
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Hi,

    I cannot reproduce the issue, and I'm not aware of any such bug.

    But there's a simple solution: Don't use w3schools, don't use alert(). Both is crap.

    w3schools is pretty much the worst site for learning I can think of. It's infamous for wrong and obsolete information, bad advice and plain nonsense. They are not affiliated with the W3C. They just use their name to -- I guess -- trick people into believing they're an "official" website and to sell their useless certificates. There are desparate attempts of driving people away from that site, but obviously w3schools still manages to pop up in every search result and fool people that are new to web programming.

    The alert() function is terrible for usability. It blocks the whole browser window and everything happening of the page. This function is just useless, it's one of those leftovers from the 90s. If you wanna display a message to the visitor, use one of the many messagebox libraries. If you wanna do debugging, use console.log().

    If you're looking for good information, the Mozilla developer network is a great resource:

    https://developer.mozilla.org/en-US/learn/javascript

    Comments on this post

    • Winters agrees
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  8. #5
  9. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,008
    Rep Power
    2791
    Oh, I missed the localhost mention. Browsers tends to block scripts running locally. Do you want to circumvent the security or were you just looking for the reason?

    [EDIT] Err, brain error, wrong forum, wrong language.

    Is Javascript enabled in Chrome?
    Settings -> Show Advanced Settings > Content Settings > Javascript
    Last edited by Winters; April 12th, 2013 at 08:30 AM.
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  10. #6
  11. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    He does get an alert box, it's just that there's some default text instead of the message.

    Anyway, I think it's pretty useless to continue fumbling with that stuff. It's of no pratical use, and you don't learn anything from it. Just ignore it, p4aul.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    11
    Rep Power
    0
    Originally Posted by Jacques1
    He does get an alert box, it's just that there's some default text instead of the message.

    Anyway, I think it's pretty useless to continue fumbling with that stuff. It's of no pratical use, and you don't learn anything from it. Just ignore it, p4aul.
    Thanks for all the replies. Actually what I was doig was trying out Marqetta and the tree widget from Dojo. When you click on a node you can cause an event and I just use that to open an Alert box to give some more info. I was using it to display a family tree. I'm surprised it worked actually because I (an most people) have popup windows blocked in their bnrowsers. Is there a fool-proof way to show more information that would not be blocked by a browser, say a widget from some library or other?
    Thanks,
    Paul
  14. #8
  15. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

IMN logo majestic logo threadwatch logo seochat tools logo