Ask a Question related to Macromedia Dynamic HTML, Design and Development.
-
jr_serrano #1
passing variable to javascript pop-up window
Hi,
I have got a bookmarking application for a set of online English learning
activities so that a user can bookmark his progress and return to where he was
in the activity. To do this he creates a cookie which tells the application
where to go.
I have got a mainpage.htm file which triggers a link to the page if the
bookmark cookie exists, then on every page I have a bookmark button which
activates a pop-up window; bookmark.htm, which has the script to create the
cookie with the number of the page the user is on. Each of the pages are
numbered 101.htm, 102.htm, 103.htm, etc. so I create a cookie with the number
101, 102, 103, etc. However, this implies creating 1 bookmark.htm file for
every activity, and there are over 100!
Can I pass a page number variable to the bookmark.htm file through the popup
window or do I have to have an individual bookmark.htm file for each page with
the number reference, ie 101bookmark.htm, 102bookmark.htm, etc?
This script works perfectly, but I don't really want to create 100
bookmark.htm files if I can pass a variable.
Thanks.
I include code below;
The bookmark button that activates the window:
<input type=button value="Bookmark" onClick="openWindow('Bookmark.htm');">
The pop-up window code:
<!-- Open Bookmark ************************************************ -->
<script language="JavaScript">
<!-- hide from JavaScript-challenged browsers
function openWindow(url) {
popupWin = window.open(url, 'remote',
'resizable,dependent,width=325,height=250,left=350 ,top=200')
}
// done hiding -->
</script>
The bookmark.htm file:
<!-- setCookie, getCookie(), and killCookie are defined in cookies.vbs -->
<SCRIPT SRC="../../cookies.vbs" LANGUAGE="VBScript"></SCRIPT>
<link href="../../stylesheet.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</HEAD>
<body onload=RemoveCookies>
<SCRIPT LANGUAGE="VBScript"><!--
'Check to see if exercise number is already in cookie. If not, ask for that
number now.
Public PageName
Sub StartItBoy()
PageName = getCookie("PageNameCookie")
'If PageNameCookie not found, get page name.
If PageName = NOT_FOUND Then
PageName = "101"
While PageName = ""
PageName = "101"
Wend
End If
setCookie "PageNameCookie", PageName
Continueit
End sub
'This procedure is run after the page is loaded. Globally fill in the
page's name between <SPAN ID="PageName">...</SPAN> tags.
Sub ContinueIt()
'First define the collection, and set up a loop to step through it.
Dim nameCollection
Set nameCollection = document.all("PageName")
For x = 0 to nameCollection.length - 1
'Bold the page's name using the <B>...</B> tags.
nameCollection.item(x).innerHTML = "<B>" & pageName & "</B>"
Next
NotBookmarked.style.visibility = "hidden"
Bookmarked.style.visibility = "visible"
End Sub
</SCRIPT>
<SCRIPT FOR="killer" EVENT="onload" LANGUAGE="VBScript">
'Get the cookie to make sure it exists.
visitorName = getCookie("PageNameCookie")
If PageName = "NOT_FOUND" Then
MsgBox("Cookie not found! Already deceased.")
Else
killCookie("PAgeNameCookie")
MsgBox("Cookie variable deceased.")
End If
Bookmarked.style.visibility = "hidden"
</SCRIPT>
<SCRIPT LANGUAGE="VBScript">
Sub RemoveCookies()
'Get the cookie to make sure it exists.
PageName = getCookie("PageNameCookie")
If PageName = "NOT_FOUND" Then
exit sub
Else
killCookie("PageNameCookie")
End If
End sub
</SCRIPT>
<table width=80% id="Bookmarked"
style="position:absolute;top:50;left:10;visibility :hidden;">
<tr>
<td>
<p>You have bookmarked exercise; <SPAN ID="visitorName"></SPAN></p>
<p>Now that exercise <SPAN ID="PageName"></SPAN> is
bookmarked, you can return to exercise <SPAN ID="PageName"></SPAN> when
you return.</p>
</td></tr>
</table>
<table width=80% id="NotBookmarked"
style="position:absolute;top:71px;left:36px;visibi lity:visible;">
<tr>
<td>
<p>If you want to bookmark your exercise, click on the bookmark button.</p>
</td></tr>
</table>
<input type="submit" name="BkmarkBtn" value="Bookmark" onclick="StartItBoy" >
<input type="button" onclick="window.close()" value="Close Window">
</BODY></HTML>
jr_serrano Guest
-
Passing URL info to pop-up window? ASP...
Hi, I'm working on an ecommerce site and want to add the ability for people to click the product image to see an enlarged pic in a pop-up window.... -
Passing CF Arrays to javascript
Hello, I have an 1 dimensional Coldfusion array that I need to access from Javascript. When a user selects an item out of a list box, a call is... -
Passing JavaScript values
I've created a JavaScript that totals a column of numbers input by a site visitor. Is there a way to bring that information with me when I jump to a... -
Passing variables from ASP to Javascript
I am using ASP to open a text file on the server and I want to pass variables to Javascript. Any suggestions? For example - I have a text file... -
passing javascript variable into asp variable using vbscript
The subject pretty much sums up what I need to do. Here is what I have so far, but still can't figure out how to get it working: <script...



Reply With Quote

