Shaye Larsen
asked on
Cannot get url variable to load into iframe src.
I have a variable that is passed in the url to an iframe which holds another child iframe. My objective is to get the variable from the url to go to the iframe and write in the child iframe src.
I can do this with <a tags and other parts of the site. But for some reason, I can't get the variable to properly display inside the iframe src attribute.
I can do this with <a tags and other parts of the site. But for some reason, I can't get the variable to properly display inside the iframe src attribute.
Here is the original link.
<a class="underline" target="iframe_i_contain" href="<%= response.encodeURL("DynamicPagesEditServlet?action=&success=m1_dynamic_nav_contain.jsp&error="+request.getServletPath()+"&"+com.ideaorbit.servlets.DynamicPagesEditServlet.HTTP_REQUEST_FIELD_KEY_ABOUT_PAGE_ID+"="+ResponseBean.getDynamicPagesID(i)+"&"+com.ideaorbit.servlets.DynamicLayoutsEditServlet.HTTP_REQUEST_FIELD_KEY_ABOUT_LAYOUT_ID+"="+ResponseBean.getSiteHomepageReference(i) ) %>"
onclick="doBoth();"><%= ResponseBean.getDynamicPagesAlias(i) %></a>
Here is the same link rendered.
<a class="underline" target="iframe_i_contain" href="DynamicPagesEditServlet?action=&success=m1_dynamic_nav_contain.jsp&error=/m1_dynamic_landing.jsp&dynamic_pages_id=135&dynamic_layouts_id=232"
onclick="doBoth();">BBCode3</a>
The variable "dynamic_layouts_id" is the variable I need to pass. Again, it passes just fine all over the site. Just not into this iframe src attribute.
Here is the iframe src attribute that I am trying to get it to display in.
<iframe name="iframe_i_edit" frameborder="0" width="100%" height="400" align="top" src="<%= response.encodeURL("DynamicLayoutsEditServlet?action=&success="+ResponseBean.getDynamicPagesTemplateReference(0)+"/editnone"+ResponseBean.getDynamicLayoutsLayoutByLayoutId(ResponseBean.getDynamicLayoutsID(0))+".jsp&error="+request.getServletPath()+"&"+com.ideaorbit.servlets.DynamicLayoutsEditServlet.HTTP_REQUEST_FIELD_KEY_ABOUT_LAYOUT_ID+"="+ResponseBean.getDynamicLayoutsID(0)+"&"+com.ideaorbit.servlets.DynamicPagesEditServlet.HTTP_REQUEST_FIELD_KEY_ABOUT_PAGE_ID+"="+ResponseBean.getDynamicPagesID(0) ) %>">
The ResponseBean.getDynamicLayoutsID(0) is the same function I use to grab this variable in other parts of the site, but it not working here. Here is the same iframe rendered.
<iframe name="iframe_i_edit" frameborder="0" width="100%" height="400" align="top" src="DynamicLayoutsEditServlet?action=&success=0001/editnone1.jsp&error=/m1_dynamic_nav_contain.jsp&dynamic_layouts_id=190&dynamic_pages_id=135">
You will see the dynamic_layouts_id is 190. That is just the first record in the database, but not the one that the above link is sending. It should be 232 in this case.
I had some luck in another part of my site using a javascript to write out the iframe and pass the variables in, but no luck here. Here is the javascript.
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
<!-- //
var dynamic_pages_id=<%= ResponseBean.getDynamicPagesID(0) %>;
var template_reference=<%= ResponseBean.getDynamicPagesTemplateReference(0) %>;
var layouts_layout=<%= ResponseBean.getDynamicLayoutsLayoutByLayoutID(ResponseBean.getDynamicLayoutsLayout(0)) %>;
var dynamic_layouts_id=<%= ResponseBean.getDynamicLayoutsID(0) %>;
document.write('<iframe src="000'+template_reference+'/editnone'+layouts_layout+'.jsp?dynamic_pages_id='+dynamic_pages_id+'&dynamic_layouts_id='+dynamic_layouts_id+'" name="iframe_i_edit" frameborder="0" width="100%" height="400" align="top">');
// -->
</SCRIPT>
Here is that javascript rendered.
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
<!-- //
var dynamic_pages_id=135;
var template_reference=0001;
var layouts_layout=1;
var dynamic_layouts_id=190;
document.write('<iframe src="000'+template_reference+'/editnone'+layouts_layout+'.jsp?dynamic_pages_id='+dynamic_pages_id+'&dynamic_layouts_id='+dynamic_layouts_id+'" name="iframe_i_edit" frameborder="0" width="100%" height="400" align="top">');
// -->
</SCRIPT>
Again, the 190 is displayed, not the 232.
ASKER
Right, that is the specific value I want passed into it originally. However, ResponseBean.getDynamicLay outsID represents the variable. SiteHomepageReference is just one of several values I would like to pass to that variable. But as you can see, I can't even get that one to pass successfully.
What does doBoth do?
& should be & in all the hrefs
I'd have to lookup details, but you may need to replace / with %2f
I'd have to lookup details, but you may need to replace / with %2f
ASKER
Do both is a javascript that allows me to populate two iframes from one link. The link itself populates one, and the doBoth javascript populates the other. The script is below.
<script type="text/javascript">
function doBoth() {
frames['iframe_i_nav'].location.href = '<%= response.encodeURL("DynamicPagesEditServlet?action=&success=m1_dynamic_nav1.jsp&error="+request.getServletPath()+"&"+com.ideaorbit.servlets.DynamicPagesEditServlet.HTTP_REQUEST_FIELD_KEY_ABOUT_PAGE_ID+"="+ResponseBean.getDynamicPagesID(0)+"&"+com.ideaorbit.servlets.DynamicLayoutsEditServlet.HTTP_REQUEST_FIELD_KEY_ABOUT_LAYOUT_ID+"="+ResponseBean.getSiteHomepageReference(0) ) %>"';
}
</script>
So maybe that is the issue? That the URL in the doBoth is not correct
you're not encoding the parameters in your url
ASKER
mplungjan
The url in the doBoth is working good. It populates the correct iframe with the information I need it to. Its the link in the main link that is not working.
It seems to me there is a difference between having a link send variables directly to an iframe vs having a page load on iframe with the <iframe> tag and have variables in the src attribute of that tag. Having a link target an iframe and sending variables gives me no trouble, but having a page that loads an iframe upon rendering does not transfer the variables.
Or my variable is not even getting to that point.
The url in the doBoth is working good. It populates the correct iframe with the information I need it to. Its the link in the main link that is not working.
It seems to me there is a difference between having a link send variables directly to an iframe vs having a page load on iframe with the <iframe> tag and have variables in the src attribute of that tag. Having a link target an iframe and sending variables gives me no trouble, but having a page that loads an iframe upon rendering does not transfer the variables.
Or my variable is not even getting to that point.
ASKER
Continuing from what I said above.
I need to make a correction, the variable I am having trouble with is a session variable. IE, it is only defined and passed through the URL. I can get variables to work that are stored in the database. But this particular one is defined on the fly. Perhaps that has something to do with it.
This has been no trouble for me when passing like this to other parts of the site, just in this iframe src tag.
I need to make a correction, the variable I am having trouble with is a session variable. IE, it is only defined and passed through the URL. I can get variables to work that are stored in the database. But this particular one is defined on the fly. Perhaps that has something to do with it.
This has been no trouble for me when passing like this to other parts of the site, just in this iframe src tag.
ASKER
thehagman
I tried replacing the & with & in the links that are associated with this problem with no effect.
I tried replacing the & with & in the links that are associated with this problem with no effect.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ResponseBean.getSiteHomepa