View Full Version : "make us homepage" event in Flash?
laursen
05-20-2005, 06:28 AM
Hi All,
I m trying to put a button on my banner that will make my page as users' homepage. I wrote down a function and other stuff in HTML (the html code is below). And in flash I called this function with getURL("javascript:fnSet()"). But when I browse the page it gives error (it says that it s not allowed). However when I call other functions with this method , I dont have any problem.
How can I make setHomePage event in Flash Actionscript or how can I call that function with flash?
HTML CODE=(
<HTML XMLNS:IE>
<STYLE>
@media all {
IE\:HOMEPAGE {behavior:url(#default#homepage)}
}
</STYLE>
<script language="javascript">
function fnSet(){
oHomePage.setHomePage("http://www.kosgeb.gov.tr");
event.returnValue = false;
}
</script>
<IE:HOMEPAGE ID="oHomePage" />
)
oldnewbie
05-20-2005, 07:01 AM
http://flashmove.com/forum/archive/index.php/t-8186
laursen
05-20-2005, 08:03 AM
hey oldnewbie,
I tried this => on(release) {
getURL("javascript:this.style.behavior='url(#default#homep age)';this.setHomePage('http://www.yoursite.com');")
}
but it says "this.style is null or not a object", then I introduced the name of my page as oHomepage => <IE:HOMEPAGE ID="oHomePage" />
then it gives this error( it s not allowed)
if all the code is correct, the could it be related with the settings of my comp?
catbert303
05-20-2005, 08:35 AM
I think the javascript keyword "this" is meaningless from within the getURL, however you can work around it like this,
in the page that contains the movie add the following javascript in between the opening <head> and closing </head> tags,
<script type="text/javascript">
function setHome() {
if (document.getElementById && document.all && !window.opera) {
obj = document.getElementById('home');
obj.style.behavior='url(#default#homepage)';
obj.setHomePage(location.href);
}
}
</script>
then somewhere in your page add an empty link like this,
<a href="#" id="home"></a>
finally in flash you can call the function using,
on (release) {
getURL("javascript:setHome();");
}
laursen
05-20-2005, 10:21 AM
Ty Catbert I tried your code but it still gives the same error:(
Anyway thanks for your all help, I dont know the reason but there is a problem with my IE explorer I guess. When I call the function (fnSet) by a HTML button, there isnt any problem and it s working. but when I called the same function with a flash button, I get the following error; "it s not allowed". Can it be related with the security settings of IE or Windows service pack2?
HTML CODE=(
<HTML XMLNS:IE>
<STYLE>
@media all {
IE\:HOMEPAGE {behavior:url(#default#homepage)}
}
</STYLE>
<script language="javascript">
function fnSet(){
oHomePage.setHomePage("http://www.kosgeb.gov.tr");
event.returnValue = false;
}
</script>
<IE:HOMEPAGE ID="oHomePage" />
)
catbert303
05-20-2005, 11:05 AM
It seems IE may have got a little smarter/stricter since I wrote that, however the following seems to make it happy again (at least it does on my work machine),
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>homepage</title>
<script type="text/javascript">
function init() {
var obj = document.getElementById('home'); // find our fake link
obj.onClick = function() { // and give it an onClick event
this.style.behavior='url(#default#homepage)';
this.setHomePage(location.href);
}
}
function setHome() {
if (document.getElementById) {
var obj = document.getElementById('home'); // find the link,
if (obj.onClick) {
obj.onClick(); // call its onClick handler
}
}
}
if (window.attachEvent && !window.opera) { // opera supports attachEvent but we don't want it doing the add home page stuff
window.attachEvent('onload', init);
}
</script>
</head>
<body bgcolor="#ffffff">
<a href="#" id="home"></a>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="550" height="400" id="homepage" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="homepage.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="homepage.swf" quality="high" bgcolor="#ffffff" width="550" height="400" name="homepage" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>
</html>
Inside the movie it has the same call to the setHome function, like this,
on (release) {
getURL("javascript:setHome();");
}
laursen
05-20-2005, 12:18 PM
Ty Catbert but no chance:)
my explorer doesnt allow me to reach "setHomePage" function by flash. error msgs show "sethomepage" line and says "not allowed". I m posting the html file. If it works on your comp, then this means that there is a problem with my comp settings or at least explorer settings
catbert303
05-20-2005, 12:55 PM
interesting... the first version of the code I posted was written a couple of years ago. it was ok then (probably for IE 5.x) but, like you found, my copy of IE 6 here tells me its "not allowed".
The second version (the one from your zip file) does work for me - if I either click the submit button in the html or from a getURL in the flash movie. It could well be an SP2 issue - I don't think we've had it installed here.
laursen
05-20-2005, 04:50 PM
yes Catbert,
I d installed SP2 in my comp. I tested the page on a comp that SP2 is not installed and it s working on that comp. So probably the problem is related with SP2. this showed me that it s too hard to make a nice webpage for all browsers and operating systems. and in my case I dont know how to handle this problem for SP2:)
Anyway thanks for your all effort, at least we ve learnt that we cant call setHomePage function in SP.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.