Solved

please explain how a javascript and img button works

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Javascript: Mouseup doesn't follow mousedown 13 60
PHP Command to Open New Tab/Page using Window.Open 3 33
Display Flex does not Wrap Items 2 46
close window in firefox 3 37
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

732 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