开发者

Script generated image onclick event change

开发者 https://www.devze.com 2023-02-21 02:34 出处:网络
I have two scripts inside my webpage <script type=\"text/javascript\" src=\"http://somesite/somefile.js\"></script>

I have two scripts inside my webpage

<script type="text/javascript" src="http://somesite/somefile.js"></script>
                     <script type="text/javascript" >somecode('a','1z4j73');</script>

This script is generating a visitor map on my web page, now I don't want my user to click on the script and get redirect to that website.

How can I restrict that?

can I make a div tag and make all element inside the div tag to read only?

I have make sure that this restriction doesn't falls under company rules, they just want their logo under the map.

EDIT1

Can I catch this thorugh any event and again开发者_StackOverflow redirect the user to the default page?

Like when user click the image, I check the URL and if the URL contains that site name I again redirect to the default page.


I guess you create the sitemap for search engine optimization, and would like to keep sitemap links accessible for search engines (indexers), but want to get rid of redirect functionality for visiting users.

If that is so, then all you need to do - is just to assign your own onclick function to all links in your sitemap.

    // onClick event
    onClickFunction = function ( ) {   
        return function ( ) {
            // do nothing
            return false;
        }
    };


<a href="http://some_url" onclick="onClickFunction();">something</a>

or simply:

   <a href="http://some_url" onclick="return false;">something</a>

this will still work for search indexers, which will look for all <a> tags and read href value. But because of "return false;" in the onClick event handler function - the redirection for users will be disabled.

Please see this article http://www.bradino.com/javascript/onclick-return-false/


If you can figure out what the HTML elements are that you don't want, you can remove them using a script library like JQuery:

$("#targetelement").remove();

Or replace it with your own content.

You don't need a script library to do this though, but it can be helpful to have one.

HTH.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号