0

In my JS i"ve got an IF condition. I want to be able to make a pop-up appear in my html page. How can I make the below pop up appear in javascript?

<a href="#x" class="overlay" id="welcome_message"></a>
     <div class="popup">
          <h2>Welcome</h2>
          <p>blah blah...</p>
     <div>
          <label for="name">Name</label>
          <input type="text" id="name" value=""/>
     </div>
</div>

3 Answers 3

1
prompt('Welcome\nblah blah...\n\nName');

would make a dialog box appear that says:

page. com says:

Welcome
blah blah...

Name ___________

Demo

\n Creates a new line, and prompt takes user input.

Sign up to request clarification or add additional context in comments.

10 Comments

exactly... but how can I trigger this via my js file?
@AnnaZeed That's the code that goes in the JS file, do I not understand correctly?
Ok. 1). There is a custom welcome message in my HTML page. 2). There is an external JS file connected to this HTML page by the <script src="... tag. 3). I want to trigger the welcome message in the HTML page through the javascript file. How?
@AnnaZeed Can you be more clear on "trigger the welcome message"? Is it hidden?
sorry... yes it's hidden. YOu'll get a better idea here
|
0

Try this (jQuery):

$(document).on('click', '#welcome_message:not(.active)', function(){
    $(this).addClass('active');
    $('.popup').show();
    return false;
})
.on('click', '#welcome_message.active', function(){
    $(this).removeClass('active');
    $('.popup').hide();
    return false;
});

1 Comment

Thanks coder3. But I'm looking for a way to trigger the HTML popup <div class="popup"> via javascript?
0

Use js plugin like bootstrap or modal pop up. These plugin will provide css and different functionality as well. Bootsrap

Edited

You can find demo at following link http://getbootstrap.com/javascript/#modals If still you are facing any problem please let me know.

1 Comment

It will be more helpful if you add any code related to it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.