Solved

please explain how a javascript and img button works

Posted on 2013-11-21
6
239 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
  • 2
  • 2
6 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now