[Answer]-How to avoid referer checking in django?

1👍

document.getElementById() returns only one item (the first item, because all images in you code have same id). Use another methods like document.getElementsByClassName.

Try following code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
{% load staticfiles %}

<html>
    <head>
        <meta charset="utf-8" />
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <script type="text/javascript" src="{% static "js/ReferrerKiller.js" %}"></script>
        <title>island</title> 
    </head>

    <body> 
        <h1> nanpa </h1>
        <br/>

    {% for entrySummary in entrySummaryList %} 
        title :
        <a href="{{entrySummary.entry_link}}">{{ entrySummary.entry_title }}</a>
        {{ entrySummary.entry_pub_date }} <br/>

        description : {{ entrySummary.entry_description }} <br/>
        image : <span class="image_kill_referrer"></span>
    {% endfor %} 
        <script>
        var i, images = document.getElementsByClassName('image_kill_referrer');
        var urls = [
    {% for entrySummary in entrySummaryList %} 
            "{{ entrySummary.entry_representaion_img }}",
    {% endfor %}
            "DUMMY"
        ];
        for (i = 0; i < images.length; i++) {
            images[i].innerHTML = ReferrerKiller.imageHtml(urls[i]);
        }
        </script>
    </body>
</html>

Or, use different id for each image:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
{% load staticfiles %}
<html> 
    <head>
        <meta charset="utf-8" />
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <script type="text/javascript" src="{% static "js/ReferrerKiller.js" %}"></script>
        <title>island</title> 
    </head>
    <body> 
        <h1> nanpa </h1> 
        <br/>

    {% for entrySummary in entrySummaryList %} 
        title : 
        <a href="{{entrySummary.entry_link}}">{{ entrySummary.entry_title }}</a>
        {{ entrySummary.entry_pub_date }} <br/>

        description : {{ entrySummary.entry_description }} <br/>
        image : <span id="image_kill_referrer{{ forloop.counter }}"></span> 
        <script>
        document.getElementById('image_kill_referrer{{ forloop.counter }}').innerHTML = ReferrerKiller.imageHtml("{{
        entrySummary.entry_representaion_img }}");
        </script>   
    {% endfor %}   
    </body> 
</html>

Leave a comment