<a> tag with OnClick()...

I want to add an OnClick event to the following line:
<a id="A4c" href="./Videos.html#UploadVideo" ><abbr title="watch demo video.">Data Upload</abbr></a>

Open in new window


It is supposed to show a message also navigate to href="./Videos.html#UploadVideo".

But this cannot be like alert box because it may mess up navigation.

Question: How can I incorporate something like toast (Demo:http://codeseven.github.io/toastr/demo.html) with this tag?

BTW, when I try something like:
<a id="A4c" href="./Videos.html#UploadVideo" onclcik="showSomething()"><abbr title="watch demo video.">Data Upload</abbr></a>

Open in new window

Understandably, it doesn't work I guess because <a> doesn't function like button on a form. So, how one fire from <a> or basically perform what has been described above?
LVL 34
Mike EghtebasDatabase and Application DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
But this cannot be like alert box because it may mess up navigation.
Can you elaborate?

How will the message be dismissed - must the user click a button or does it just show for a period and then navigate to url.
0
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
I have 4 hyperlinks in index.html and 4 descriptions + vidoes on videos.html.

Problem: When user clicks on a hyperlink on index.html, it navigates to vidoes.html but it is not clear to the user which of the videos s/he must concentrate.

Desired solution: The caption of the target video could change color to red, or blink several times.

But because there is no session variables etc, a messaging like toast is also acceptable in the following manner:
1. User clicks on the hyperlink ("Search video").
2. A mesage appears on the upper right corner of the screen telling user "please see item 3. Search video" for example. This message ideally better to appear on vidoes.html and close after a second or two. But, it will be okay just to show this message on index.html just before navigating to vidoes.html. But this simple request may have its own complication causing delay in navigation.

Any other solution helping the user what video to watch is also acceptable.

Thanks,

Mike
0
Julian HansenCommented:
But because there is no session variables
Why not use a cookie?

If I understand your request you want to have the index.html link "focus" on the corresponding video on the video page?

Why not have the link open in a modal when clicked
Example
CSS
.overlay {
  width: 100%;
  background: rgba(0,0,0,.75);
  position: absolute;
  left: 0;
  top: 0;
}
.videobox {
  width: 50%;
  position: absolute;
  left: 50%;
  margin-left: -25%;
  top: 10%;
  background: white;
  text-align: center;
  padding: 20px;
  border-radius: 5px;
  
}
.close {
  width: 36px;
  height: 36px;
  position: absolute;
  top: -18px;
  right: -18px;
  display: block;
  background: transparent url(images/close.png) no-repeat center center;
  opacity: .8;
}
.close:hover {
  opacity: 1;
}

Open in new window

HTML
    <ul>
      <li><a class="video-link" href="http://www.sample-videos.com/video/mp4/480/big_buck_bunny_480p_1mb.mp4" data-description="This is the description for sample video #1">Video 1</a></li>
      <li><a class="video-link" href="http://techslides.com/demos/sample-videos/small.mp4" data-description="This is the description for sample video #1">Video 2</a></li>
    </ul>

Open in new window

jQuery
$(function() {
  $(document).on('keyup',function(e) {
    if (e.keyCode == 27) {
      $('.overlay').remove();
    }
  });
  $('body').on('click','.overlay, .close', function() {
    $('.overlay').remove();
  });
  $('body').on('click','.videobox', function(e) {
    e.stopPropagation();
  });
  $('.video-link').click(function(e) {
    var el = $(this);
    e.preventDefault();
    $('body')
      .append(
        $('<div class="overlay"/>').height(Math.max($(document).height(), $(window).height()))
        .append(
          $('<div/>').addClass('videobox')
            .append($('<a/>').addClass('close'))
            .append($('<video/>').prop('autoplay', true).attr('src', el.attr('href')))
            .append($('<div/>').html(el.data('description')))
        )
    );
  });
});

Open in new window

Working sample here
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
0
Julian HansenCommented:
You are welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.