Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

An alternative to using frames 1

Status
Not open for further replies.

seabaz2000

IS-IT--Management
Feb 24, 2006
79
0
0
IE
Hi I am currently building a website that contains a flash header with a navigation bar. I have currently split framed the site site and when a user clicks on one of the navigation buttons the appropriate page loads on the bottom frame. I wish to abandon the use of frames as they are a rather redundent technology and try to use somthing else to load my webpages into. I am open to all suggestions really. Is there anyway that you can get the flash header to jump straight to the end at the page load which would stop the movie from playing everytime a user traveresed to a page that contained the flash header.
Regards
 
yeah have heard about using div's alright. Do how would you target a certain div with a hyperlink like you can target a frame and get a page to load up on it or have I the wrong concept altogether.
Regards
 
The usual way is like this:

document.getElementById("divID").innerHTML = "Some new HTML content"

This will dynamically change the content of the following <div> tag:

<div id="divID">Some existing HTML content</div>

Kenneth Kawamoto
 
The flash buttons I am using are contained within a flash movie, and the document.getElementById("divID").innerHTML = "Some new HTML content" doesn't seem to work for these types of buttons.
 
I don't know how you're utilising this, but I've just done a test and it worked fine on IE and FireFox (PC).

The trick is you call the Javascript function in the HTML from the SWF.

An example:

Flash
[tt]// AS2 main timeline
aButton.onPress = function():Void {
getURL("javascript:replace(\"Some new HTML content\")");
};
//[/tt]

Javascript in HTML
[tt]//
function replace(arg){
document.getElementById("divID").innerHTML = arg;
}
//[/tt]

Kenneth Kawamoto
 
Kenneth
Thank you so much for your help. I am still getting errors with my flash buttons though. Here is the code that sits behind the flash button.
Code:
on (rollOver) {
	gotoAndPlay("01");
}
on (releaseOutside, rollOut) {
	gotoAndPlay("02");
}
on (release) = function():Void { 
getURL("javascript:replace(\"Some new HTML content\")");
}
I keep getting the following error
**Error** Symbol=menu01, layer=Layer 12, frame=1:Line 7: '{' expected
on (release) = function():Void {

Total ActionScript Errors: 1 Reported Errors: 1


Thank you so much again.
 
Kenneth
I have removed the :Void and the problem still occurs.
The code is now
Code:
on (rollOver) {
	gotoAndPlay("01");
}
on (releaseOutside, rollOut) {
	gotoAndPlay("02");
}
on (release) = function(){ 
getURL("javascript:replace(\"Some new HTML content\")");
}
and the error is
**Error** Symbol=menu01, layer=Layer 12, frame=1:Line 7: '{' expected
on (release) = function(){

Total ActionScript Errors: 1 Reported Errors: 1

.
Once again thanks for all the help.
 
Kenneth
That sorted out the problem with the link. So now I have inserted the following javascript at the top of the page.
Code:
<!--
<script type="text/javascript">
function replace(arg){
    document.getElementById("divIDx1").innerHTML = arg;
	alert("Testing the function was called!");
}

</script> 
-->

And I have the following further down in the code
Code:
<div id="divIDx1"> Some existing HTML content </div>

But by clicking on the button doesn't seem to be calling the function "replace", as alert message does not pop up to confirm it.
Thanks ever so much again.
 
> But by clicking on the button doesn't seem to be calling the function "replace", as alert message does not pop up to confirm it.

Isn't it because you commented out entire Javascript?

Kenneth Kawamoto
 
Kenneth
Here is the code minus the comments, still nothing occurs
Code:
<html>
<head>
<title>Home</title>
<meta http-equiv="Content-Style-Type" content="text/css">
<LINK HREF="style.css" TYPE="text/css" REL="stylesheet">
<script language="JavaScript" type="text/JavaScript">




function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}



</script>

<script type="text/javascript">
function replace(arg){
    document.getElementById("divIDx1").innerHTML = arg;
	alert("Testing the function was called!");
}

</script> 


</head>

<body>
 
It will fail if you don't have an element called "divIDx1" in your HTML and the code stops there so you'll get no alerts.

Put alert() at the top, then you'll get the alert even the subsequent line of code fails.

(I copy & pasted your HTML and all worked fine, by the way.)

Kenneth Kawamoto
 
Hi
I am sorry to be bothering you all again, but I still can't seem to be able to get this little piece of functionality going so much so that I'm determind to get the flash button just to output a simple alert box so that I can see that when I click on it, it is doing something. I have placed the following code behind the button but it seems to be doing nothing.
Code:
on (rollOver) {
	gotoAndPlay("01");
}
on (releaseOutside, rollOut) {
	gotoAndPlay("02");
}
on (release) {
	  getURL("javascript:alert('Hello World');");
}
I can't seem to get a handle on this flash at all!!
Regards
 
Hi,
on (release) {
getURL("javascript:alert('Hello World');");
}
Well, this is the simplest Javascript call from Flash and this should even work on IE(!)

If this doesn't work there's definitely something wrong with your setup. Do you actually have Javascript enabled in your browser?

Or going to Flash Player Global Security Settings manager < and adding your Flash dev directory may fix the problem.

Kenneth Kawamoto
 
Hi
Yes it was the global security settings manager. Thank god for that. Ha. Just wondering what if another user now tries to view my webpage do they have to have their global settings changed in order to view the alert message.
Regards
And thank you very much again.
 
Hi,

I know the question in this thread has already been answered but I wondered if I could ask another question relating to this topic. (Not sure if I should be starting a new thread or not??).

Anyway, I wondered if it was possible to create a slightly different scenario to the one offered in this thread - everything would be the same, ie. the navigation buttons would be in a swf file but instead of populating the divs via javascript in the html, is it possible to have external files which would contain the information to populate the divs as each button is pressed? I guess the files could be xml or some basic text file. I mean I don't know if you'd use some other type of javascript to achieve this but can someone tell me if it's possible, and if so how I'd go about it?

Thanks for any help offered.
 
In short, it is very much possible, and there are two ways I can think of.

The first way is to use Flash to obtain the XML/Text data and pass that data to Javascript to populate the HTML contents.

The second way is to use Javascript to load the XML data. A colleague of mine has kindly pointed out this site: <It's for XML but I'm sure you can do the same for text file too.

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top