Variable in JavaScript

I am trying to pass a javascript variable to another html page, the code is below.
The first code gets the URL from where the page was loaded from.  The second script opens up the page javascript.html and sends var1 and var2 so I can use them.  this all works perfectly.  What I want to do is pass the value "parent.location" as var1.  Hitting a road block.  




FirstCode.
<script type="text/javascript">

function getParent(){

alert(parent.location);

}

</script>

Second Code.

<script type="texas/javascript"
src="javascript.html?var1=bob&var2=frank">
</script>
rbm1tch3llAsked:
Who is Participating?
 
bartvdConnect With a Mentor Commented:
Sorry, I do not get exactly what is your goal. Do you only want to call another javascript file, or do you want to load another html file? If so, you should not use <script src="..."> , but a frame.
0
 
bartvdCommented:
I don't it exactly. Do you load Firstcode using SecodeCode? Then why would you pass parent.location, because you already have it in Firstcode?
0
 
rbm1tch3llAuthor Commented:
No, I am looking up the parent.location then I am calling a page that does processing via the second code.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
bartvdCommented:
Try this:





<script type="texas/javascript"
src="javascript.html?var1="+parent.location+"&var2=frank">
</script>
0
 
rbm1tch3llAuthor Commented:
Nope doesn't work.
0
 
bartvdCommented:
You should put the javascript in a javascript file. You could call this file javascript.js, Inside it there should only be javascript, so without the script tags.
0
 
rbm1tch3llAuthor Commented:
Still doesn't work, here is my code.

TEST.HTML

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script type="text/javascript">

function getParent(){

alert(parent.location);

}

</script>
</head>

<body>

<script type="text/javascript"

src="test.js">
</script>
<script type="text/javascript">
document.write("<p>" + parent.location + "</p>");
</script>

<body>

</body>
</html>


TEST.JS
// JavaScript Document
src="javascript.html?var1="+parent.location+"&var2=frank">
0
 
rbm1tch3llAuthor Commented:
I am trying to send the parent.location to another html file via URL Variable var1.  It works perfectly sending a hard coded ...var1=Bob  over to the html file.
0
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.

All Courses

From novice to tech pro — start learning today.