Retrieve parent document value from iFrame

Working on a solution for a Sitecore CMS page that includes passing a variable from the parent page to an VBScript ASP page in an iFrame.  The code I currently have in the parent page is:
<script>
    var locationID = '@Model.IgnitionID';
    document.write(locationID);
</script>

Open in new window


And the code in the receiving iFrame page is:
<%
Dim barkBark
barkBark = ("#locationID", top.document)
%>

...later in the code...
<p>Location ID: </p>
<%response.Write(barkBark) %>

Open in new window


I know the parent page code works - the document.write shows the correct code.

When I run the code as-is, I get an 'expected ')' message, with the prompt to put it after "#locationID".  I have tried adding it there, nesting it another set of parens, changing top.document to parent.document.body.  The anticipated value is a GUID.

Any help is greatly appreciated!
chipsterva69Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
You seem to be mixing VB (server side code) and javascript (client side code) these cannot interact with directly with each other.

So (just guessing here) the following
 var locationID = '@Model.IgnitionID';

Open in new window

Should probably be
 var locationID = '<%= @Model.IgnitionID%>';

You also cannot interact with an iframe directly (for security reasons).

Can you explain a bit more about how the iframe is created and loaded? Is it not possible to put the location id into the URL for the SRC of the iframe and pass it in that way?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chipsterva69Author Commented:
@Julian Hansen - thanks for the input.  I tried getting the code you recommended to work, but as you pointed out, security prevents direct interaction.  However, we were able to create a solution that added the necessary ID to the URL being passed to the iFrame and were able to resolve the issue that way.  Thanks for the suggestion!
0
chipsterva69Author Commented:
While the original recommended code did not workout, the input offered led to the eventual solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.