[Solved] It doesn’t work (html and javascript and Iframe)


I think it’s just my mistake.

— If someone want to refer javascript function in iframe. iframe must refer source code which define function that component in body refer…

this is my solution..

  1. In ‘view.py’, define index s

    def upload_file(request):
        context = {'source_list':source_list,'menu_list':menu_list, 'form':fileform, 'index':1}
        return render(request, 'encyclopedia/maintab.html', context) 
    
  2. In ‘(template document name).html’, define what to do according to index.

    {% if index == 0 %}
        <a id="nav-{{service.menu}}-tab" class="nav-item nav-link active" role="tab" data-toggle="tab" aria-controls="{{service.menu}}-tab" href="#{{service.menu}}-tab">
              목록 보기(<- this is korean. In English "show list...")
        </a>
    {% elif index == 1 %}
        <a id="nav-{{service.menu}}-tab" class="nav-item nav-link" role="tab" data-toggle="tab" aria-controls="{{service.menu}}-tab" href="#{{service.menu}}-tab">
              목록 보기(<- this is korean. In English "show list...")
        </a>
    {% endif %}
    
  3. Don’t forgot to define iframe like below

    <form class="form-horizontal" method ="POST" action="./upload" >
        ...
        <input type="submit" id="transferbutton" value="vvvvvvvvvvvvvvv"/>
    </form>
    
  4. In ‘Urls.py’

    urlpatterns = [
        url(r'^encylopedia/index$', views.index, name="index"),
        url(r'^upload$', views.upload_file, name="upload_file"),
        url(r'^$', views.index, name="index"),
    ]
    

It is difficult to understand Django framework…
thnks.

but it makes some blink… when click button.

solved It doesn’t work (html and javascript and Iframe)