Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

please explain how a javascript and img button works

Posted on 2013-11-21
6
Medium Priority
?
253 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

618 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