Home >Web Front-end >HTML Tutorial >Solve the problem that when the parent page loads an iframe, the parameter value in the src link is too large, causing the loading to fail_html/css_WEB-ITnose
Sometimes when we use iframe, we like to write like this
Or use js Load src:
var params = "?pk_id=" pk_id;
var frameLeftSrc = "<%=path %>/ /.do" params;
$('#leftFrame').attr("src",frameLeftSrc);
(Let me explain first, here is just one parameter as an example. There may actually be multiple parameters. Let’s continue)
Both of the above two writing methods can realize the loading of iframe. We may think that there is no problem. Quite true. In fact, there is really no big problem with the above writing method. When the parameter value is not long, pay attention to the length of the parameter value, not the number of parameters. For example, I want to pass a parameter to this iframe. The parameter name is pk_id. The value is a long string of primary keys returned by the main page or other pages. It should be at least 3000 characters. At this time, we will use this There is a problem with method access. Because this URL method is submitted through get, the length of the parameters is limited.
So what should I do when transmitting this kind of big data? There are two types that I can think of at the moment (if you have any better suggestions, please feel free to share them and improve each other):
1. Still pass it in this way, but the parameter value should not be too long. The premise is that the short parameter value can be queried through association to the long parameter value you want, so that after the iframe receives the short parameter value , you then find a way to get the long parameter value you want in the iframe subpage. (It can be used, but it is not recommended because it requires a prerequisite)
2. Use the following method on the main page to load the iframe page:
Main page:
js:
var url="<%=path %>/pubitem/ toChoosePubItemLeft.do"; //Define the action of the form on the iframe page
//Define the form
var html1='
Encapsulate the above method into one method, Then calling this method when the main page is loaded will pass the big data of the main page to the iframe page.