Solved

please explain how a javascript and img button works

Posted on 2013-11-21
6
240 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

929 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

10 Experts available now in Live!

Get 1:1 Help Now