2012-06-12 2 views
0

pdf에 대한 서버 요청을 피하려면 어떻게해야합니까? 나는 visibility=hiddenwidth=0을 시도했다.HTML 개체 스타일 표시 속성 변경시 서버 호출 방지

<object class='pdfClass' data='"+conventionId+"/showPdf.html' width='100%' height='600'></object> 

function toggleConv() { 
    if (...) { 
     document.getElementById(conventionId).style.display = 'none'; 
    } else { 
     document.getElementById(conventionId).style.display = ''; //causes a refresh 
    } 
} 

답변

0

편집 :

유일한 방법은, 내가 아는 한, 요청을 방지하기 위해, 동적 객체의 URL을 추가 (또는 객체 자체를 추가) 코드에서하는 것입니다 테스트 후

, 나는 발견이 다시로드하지 않고 파이어 폭스 (13)의 다음 작품 :

<object id="test" class='pdfClass' data='https://web3.unt.edu/riskman/PDF/Guidelines_on_Staphylococcal_Infections-Athletics__Revised__06-22-06.pdf' width='100%' height='600'></object> 

function toggleConv(o){ 
    var test = document.getElementById('test'); 

    if (o == true){ 
     test.style.width = 0; 
     test.style.height = 0; 
    } else { 
     test.style.width = '100%'; 
     test.style.height = '600px'; 
    } 
} 

http://jsfiddle.net/userdude/KnEYC/2/

,824,321 0

원래 응답. 요소의 heightwidth도 동일한 공간을 계속 차지하지 못하도록 거의 없거나 전혀 변경하지 않아야합니다.

하나 개의 기술 해제 방법 화면에 배치하여보기에서 숨길하는 것입니다 : 나는 제라드에 대답으로

#test { 
    position: relative; 
} 

function toggleConv(o){ 
    if (o == true){ 
     document.getElementById('test').style.left = '-10000px'; 
     document.getElementById('test').style.top = '-10000px'; 
    } else { 
     document.getElementById('test').style.left = ''; 
     document.getElementById('test').style.top = ''; 
    } 
} 

http://jsfiddle.net/userdude/KnEYC/

+0

나는 두 가지 방법을 시도했지만, 행운도없이 pdf는 거기에 머문다. 이 객체 태그가 동적으로 생성되고 있습니다. –

+0

나는 해결책을 얻었고, 감사합니다. –

+0

원래 Jquery를 사용하여이 작업을 수행했지만 toggle()은 재로드를 유발하므로 일반 JS로갔습니다. Jquery 메서드로 다시로드를 억제 할 수 있다면 어떤 생각 이니? –

0

HTML에있는 경우로드됩니다.

if (...) { 
    // Add the data tag here 
} 
+0

는, 오브젝트 태그가 동적으로 생성되고, 해당 데이터 소스가 선택됩니다 응답 변수를 기반으로 이 JavaScript에서 변수를 가져올 수 있습니까? –