| View previous topic :: View next topic |
| Author |
Message |
davesec
Joined: 11 Sep 2008 Posts: 1
|
Posted: Thu Sep 18, 2008 4:37 am Post subject: Javascript function in advertisement_url |
|
|
First of all, great work on PageCurl! Aside from experiencing the minor, easily-fixed z-index issue initially, the script installed and worked perfectly right "out of the box." Clear and well-written instructions, as well. Worth every penny!
Now, to my question: I know that PageCurl is able to accept a javascript function within the advertisement_url. And I did notice your example of how to go about calling a javascript function within the PageCurlPro.pdf. However, that example, I believe, is a bit too simple for my needs, so I'd like to ask for some advice on how to implement a slightly more complex script.
To be specific, I'd like to use the "add search" function to allow visitors to add my webpage (a search portal) to their browser's search bar.
I have found the following example script, which should do the trick, but I do not know how to fit that multi-line script into the advertisement_url.
[code]
<a href="#" id="addSearch" style="display:none">
Add example.com search to your browser
<!-- edit the url below -->
<script type="text/javascript" language="javascript">
(function(){
//edit this to point at your opensearch.xml file
var url = "www.example.com/opensearch.xml";
var add = function(ev){
window.external.AddSearchProvider(url);
Event.stop(ev);
};
if ( typeof window.external == "object"
&& typeof window.external.AddSearchProvider != "undefined" ) {
var a = $('addSearch');
Event.observe(a, 'click', add);
a.toggle();
a=null;
}
})();
</script>[/code]
Can anyone help? Thanks! By the way, I'm a javascript novice.
|
|
| Back to top |
|
PowerUpAdmin Site Admin
Joined: 23 Feb 2007 Posts: 189
|
Posted: Thu Sep 18, 2008 3:44 pm Post subject: |
|
|
Hello. I'm not familiar with that particular script, but it appears that you will need to turn it into a function, and then call the function from the advertisement_url. Basically, you would wrap the existing function with:
function add(){
}
So, it would look like this:
<a href="#" id="addSearch" style="display:none">
<!-- edit the url below -->
<script type="text/javascript" language="javascript">
function add(){
(function(){
//edit this to point at your opensearch.xml file
var url = "www.example.com/opensearch.xml";
var add = function(ev){
window.external.AddSearchProvider(url);
Event.stop(ev);
};
if ( typeof window.external == "object"
&& typeof window.external.AddSearchProvider != "undefined" ) {
var a = $('addSearch');
Event.observe(a, 'click', add);
a.toggle();
a=null;
}
})();
}
</script>
Then, your advertisement_url would be "javascript://add();"
I hope this helps you out. |
|
| Back to top |
|
advecdodendum
Joined: 28 May 2010 Posts: 3 Location: Italy
|
Posted: Mon Jun 14, 2010 2:41 am Post subject: Javascript function in advertisement_url |
|
|
| Oh... I see that it does work under some circumstances, but its behaviour is not identical to older versions. Have to test more.
|
|
| Back to top |
|
|