PowerUpMySite.com Forum Index

Forum Index | PowerUpMySite.com Home Page
Log in Register FAQ Search PowerUpMySite.com Forum Index

Javascript function in advertisement_url

 
Post new topic   Reply to topic    PowerUpMySite.com Forum Index » Support
View previous topic :: View next topic  
Author Message
davesec



Joined: 11 Sep 2008
Posts: 1

PostPosted: Thu Sep 18, 2008 4:37 am    Post subject: Javascript function in advertisement_url Reply with quote

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
View user's profile Send private message
PowerUpAdmin
Site Admin


Joined: 23 Feb 2007
Posts: 189

PostPosted: Thu Sep 18, 2008 3:44 pm    Post subject: Reply with quote

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.



_________________
PowerUpMySite Staff
Power Up Your Site the Easy Way
http://powerupmysite.com
Back to top
View user's profile Send private message Send e-mail
advecdodendum



Joined: 28 May 2010
Posts: 3
Location: Italy

PostPosted: Mon Jun 14, 2010 2:41 am    Post subject: Javascript function in advertisement_url Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    PowerUpMySite.com Forum Index » Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001- 2004 phpBB Group
Theme created by phpBBStyles.com | Themes Database