2014-04-28 1 views
0

Iframe을 사용하고 있습니다. 일부 변수 (a 및 b)를 전달하고 방문 페이지에서 캡처해야합니다.Iframe 변수를 전달하고 방문 페이지에 캡처하기

페이지 -1

<iframe id="trackFrame" width="600" height="500" src="maps.html?A=1&B=2" frameborder="0"  
    scrolling="no" marginheight="0" marginwidth="0"></iframe> 

내가

방문 페이지에 필요한 방문 페이지에서

<body onload="initialize(passedA, passedB)"> 

이 제발 도와주세요 나는 프리젠 테이션 개발에 새로운 해요.

답변

0

여기이 게시물보고 시도해보십시오 How can I get query string values in JavaScript?

먼저 당신이 매개 변수의 배열을 전달받을 필요합니다,를 통해 수행 할 수 있습니다

var newArray = window.location.search.substr(1).split('&') 

이 pageLoad에 빈 함수를 호출하려고 그 이것을 읽는다. 그런 다음 배열은 매개 변수 문자열 window.location.search.substr(1) 을 읽은 다음 모든 것을 & 필드로 구분 된 배열로 분할하여 만들어집니다.

당신은했다 그렇다면 mysite.com/page.html?a=3 & 나 그 다음

newArray(0) = "a=3" and newArray(1) = "b=4" 

var a = newArray(0).substring(2) 
var b = newArray(1).substring(2) 

문자열 배열을 만들 것 = 4 (2) 것이다 매개 변수에서 "a ="및 "b ="을 제거하고 전달 된 매개 변수에 대한 최종 결과를 남겨 둡니다.

이렇게하면 도움이됩니다.

관련 문제