?
Solved

please explain how a javascript and img button works

Posted on 2013-11-21
6
Medium Priority
?
248 Views
Last Modified: 2013-11-27
The website docmein.com gave me this widget to use on my website:
<script type="text/javascript" language="javascript"
src="https://docmein.com/app/widget/widget.nocache.js" ></script>
<img src="https://docmein.com/app/images/schedulenow.png"
id="newAppointment_XXXX" style="cursor:pointer">

Open in new window

It creates a "Schedule Now" button that when clicked opens a scheduling window using my account. The XXXX above is replaced by my account id (it won't work with just xxxx.) If you need to see the code work, email me at nelsonh@nosuffering.com for my account id.

The code works but I do not see how the image connects to the javascript code and I would like to know how it is working.

I would also like to activate this with javascript and not display an image on my website if that is possible. What I would like to do is open the popup window in a frame with another frame next to that one with instructions.

I asked my contact at docmein.com but he is not a programmer and also does not know how it works. I would appreciate any guidance anyone could give me.

Thanks
0
Comment
Question by:thenelson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 39667481
The js file is attaching an onclick event to the image based on the image id.
If you want to do it yourself you could for example use a div
<div id="newAppointment_1234" style="cursor:pointer">Click Me</div>
0
 
LVL 39

Author Comment

by:thenelson
ID: 39667861
Yes this worked:
<div id="newAppointment_1234" style="cursor:pointer">Click Me</div>

I loaded "https://docmein.com/app/widget/widget.nocache.js" into the address bar and did not see a getElementById reference but there was an include for another .js file.

I ended up creating a 1X1 pixel image for the image and created an onload event to click the image.

The popup window looks like it pops up as a type of alert box. Is there a way to put it into a frame so I could put instructions next to it?

I did create this page to test it (and show it to you): www.barnwellmd.com/test.html
0
 
LVL 58

Expert Comment

by:Gary
ID: 39667892
Not really since it is thrown into a dialog - would probably start getting messy.
But it's too late for me know - post a comment here tomorrow to remind to come back to the question
0
 
LVL 39

Author Comment

by:thenelson
ID: 39668616
Sar1973,
I am familiar with the button and image objects. In this case the image object has no onclick event and yet, somehow, it activates a java script. I don't understand how it is doing that.

Ultimately, what I am trying to do is place the pop up dialog in a frame so I can provide the user with instructions next to the dialog box. You can see the popup dialog (with the instructions greyed out in the background) here:  www.barnwellmd.com/test.html
0
 
LVL 9

Expert Comment

by:Sar1973
ID: 39669001
One chance could be that the onclick event of the button is followed by an onload event of another page; another possibility is that there are one or more other events assigned to the button (i.e.onmouseover) or to the body tag, so that they trigger other JS functions.
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question