View Full Version : Combine href w/ onclick for iframe lightbox
visibledentist
05-21-2010, 01:13 AM
Hello,
I'm looking for a way to combine a URL destination with a highslide iframe "lightbox" application.
The code below works perfectly as is. However, since I'm using it to pull up a contact form page, I want to make the hard-wired href link javascript too, in order to avoid form spam.
<a title="Request appointment" ONMOUSEOVER="window.status='Request appointment';return true" ONFOCUS="window.status='Request appointment';return true" ONMOUSEOUT="window.status=''" href="request.php" onclick="return hs.htmlExpand(this, { objectType: 'iframe', objectHeight: 515, width: 500 } )">Request</a>
How can I use javascript with the onclick event above to also access the request.php file?
Thanks
djr33
05-21-2010, 01:22 AM
In the onclick event, the keyword "this" is used-- this refers to the current object, in this case the <a> tag.
Usually this is used as "this.href" referring to the URL given in the tag. If it were that, you could just replace it with text.
But since it's referring to the whole object, you may have to modify the function a bit to make this work.
If you want help:
1. Link to your page so we can actually see what's going on (there's a lot more code than what you've posted, and visiting the real page will give much more information than just a description).
2. Link to the script(s) you are using so we can see what their documentation is, if needed.
visibledentist
05-21-2010, 02:51 AM
In the onclick event, the keyword "this" is used-- this refers to the current object, in this case the <a> tag.
Usually this is used as "this.href" referring to the URL given in the tag. If it were that, you could just replace it with text.
But since it's referring to the whole object, you may have to modify the function a bit to make this work.
If you want help:
1. Link to your page so we can actually see what's going on (there's a lot more code than what you've posted, and visiting the real page will give much more information than just a description).
2. Link to the script(s) you are using so we can see what their documentation is, if needed.
I was hoping someone could just take a blind shot at it.
The website & page are not public at the moment; they're in development. I suppose if it's necessary, I could load up a dummy page and form w/ all the scripts in order to troubleshoot the issue.
djr33
05-21-2010, 02:54 AM
Correct, you should upload a page. Basing this metaphor on your username, asking us to help without seeing the details of the code is basically like asking a dentist to figure out what's wrong with someone's teeth before examining them.
That little bit of code isn't enough to figure out what is wrong. (It might have been, but in this case it isn't.)
visibledentist
05-21-2010, 03:39 AM
Correct, you should upload a page. Basing this metaphor on your username, asking us to help without seeing the details of the code is basically like asking a dentist to figure out what's wrong with someone's teeth before examining them.
That little bit of code isn't enough to figure out what is wrong. (It might have been, but in this case it isn't.)
Point taken -- though for the record, I'm not a dentist! :)
Let me see about getting some code up...
jb
djr33
05-21-2010, 03:59 AM
Haha, no, that's fine, just a good reference point. I don't mean to complain either, but it's just really hard to guess what's wrong.
visibledentist
05-21-2010, 04:07 AM
Haha, no, that's fine, just a good reference point. I don't mean to complain either, but it's just really hard to guess what's wrong.
Hey you're not complaining -- I totally understand & agree.
Here, I put up a test page (http://www.contactdentists.com/test.php).
jb
djr33
05-21-2010, 04:38 AM
The Javascript in the example is compressed, "encrypted". It'll need to be uncompressed (it's full, original, human-readable form) to adjust it. That's the file that needs to be changed.
visibledentist
05-21-2010, 04:49 AM
The Javascript in the example is compressed, "encrypted". It'll need to be uncompressed (it's full, original, human-readable form) to adjust it. That's the file that needs to be changed.
Darn -- bummer. :(
Oh well, w/o a method to avoid form spam, guess I won't be using it for live sites.
Thanks just the same.
jb
djr33
05-21-2010, 06:17 AM
If you are that worried about this and spam, you could dynamically write the code to the page using Javascript.
Of course this will block some users from accessing the content, but it will also (probably) stop many bots. It won't stop people who are using it to spam, though, and there is a surprising amount of spam that is actually submitted by real people, and you can't really do much to stop that.
visibledentist
05-22-2010, 01:27 AM
The Javascript in the example is compressed, "encrypted". It'll need to be uncompressed (it's full, original, human-readable form) to adjust it. That's the file that needs to be changed.
Actually only a simple tweak was needed to pass a new parameter.
<a title="Request appointment" ONMOUSEOVER="window.status='Request appointment';return true" ONFOCUS="window.status='Request appointment';return true" ONMOUSEOUT="window.status=''" href="javascript:;" onclick="return hs.htmlExpand(this, { objectType: 'iframe', src: 'request.php', objectHeight: 515, width: 500 } )">Request</a>
It works fine now. :)
jb
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.