Click to See Complete Forum and Search --> : Almost HomePage Script.


GavinPearce
04-18-2003, 03:58 PM
Ok I got this far. But what am I doing wrong for this script? I just can't figure it out!

<html>
<script>
<!--
function addToFavorites()
{
var favoriteurl = document.fm.url.value;
var favoritetitle = document.fm.ttl.value;
window.external.AddFavorite(favoriteurl,favoritetitle);
window.external.setHomePage(favoriteurl);
}
//-->
</script>
<script>
<!--
{
var homeurl = document.fm.url.value;
link = '<a href="javascript:addToFavorites();" onClick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(' + homeurl + ');">Submit</a>';
}
//-->
</script>

<form name="fm">
URL: <input name="url" size="46">
Title: <input name="ttl" size="40">
<br/>
<script>
document.write(link);
</script>
</form>
</html>

Cheers!

DrDaMour
04-18-2003, 04:09 PM
why not just use a prompt box?

GavinPearce
04-18-2003, 04:35 PM
Because I'm using it to get around my system admin res and I want a page where people can just go enter a title and url and it makes it in there favorites and homepage.

Any help ppl?

Gav :)

DrDaMour
04-18-2003, 08:09 PM
yes i know what you are trying to acheive. again why don't you just use a prompt box..probably cause you didn't look to see what it was.



var url = prompt("What is the URL?","http://")
var title = prompt("What is the Title",url)

window.external.AddFavorite(url,title);

GavinPearce
04-19-2003, 04:03 AM
I no but forms are a lot easier to handle cause you can add verification like making sure someone doesn't enter a blank input and make sure they inculde the http:// etc etc...

I am still stuck on that original script if anyone can help?

DrDaMour
04-19-2003, 10:27 AM
i hate to get in a philosophycal debate about ease, but i have to cause you are dead wrong. With a form you have to hook on change events and find the objects through document. mehtods and values.

But in a prompt box you have to do none of that, it IS an event, adn you can check the validity of my URL and TITLE just as easily (and dare i say easier) than your way.

GavinPearce
04-19-2003, 11:44 AM
Ok fit in the homepage and favorites script to the prompt boxes and I'll say your right :D

I just can't figure that bit out :confused: lol.

Gav.

DrDaMour
04-19-2003, 12:05 PM
ok, did you EVEN TRY the code i pasted already. Why do people refuse to try things.....

well i just tried it and it worked exactly like i said it would.

and because you are unable to copy and paste my earlier code, i'm certain that copying and pasting the code here will probalby also be fruitless. But i will do it anyways on the off change that you'll actually attempt it this time.


<html>
<script>
<!--
function addto()
{

var url = prompt("What is the URL?","http://")
var title = prompt("What is the Title",url)

window.external.AddFavorite(url,title);
}
//-->
</script>


<input type="button" onclick="addto()">


</html>


look at that, it's EXACTLY what i posted 4 posts ago..imagine

GavinPearce
04-19-2003, 12:17 PM
Lol yea ok if u say so, but before I try it, wheres the set homepage script in that?

ok, did you EVEN READ the message i put earlier. Why do people refuse to read things..... :p

Lol i'd like an aplogy but I no i aint gonna get it ;)

Gav. :cool:

DrDaMour
04-19-2003, 12:34 PM
where is it taht you said you were having probles specifically with the homepage part? nowhere

<html>
<script>
<!--
function addto()
{

var url = prompt("What is the URL?","http://")
var title = prompt("What is the Title",url)

window.external.AddFavorite(url,title);

return url;

}
//-->
</script>


<input type="button" onclick="this.style.behavior='url(#default#homepage)';this.setHomePage(addto());">


</html>

GavinPearce
04-19-2003, 12:45 PM
In the first script it clearly shows the use of the homepage script in the test link and in my request to you it says:
Ok fit in the homepage and favorites script to the prompt boxes and I'll say your right :D

But hey the script works and I'm happy so thank you very much mate. :) :) :) :) :p :D

Vincent
04-19-2003, 01:25 PM
why do you need that script, but ok...

<HTML>
<SCRIPT>
function ok() {
var1 = document.hello.world.value
var2 = document.hello.dad.value

window.external.AddFavorite(var1,var2);
}
</SCRIPT>

<FORM name="hello">
name: <INPUT type="text" name="world">
url: <INPUT type="text" name="dad"
<INPUT type="button" onclick="javascript:ok()">

</HTML>

Vincent
04-19-2003, 01:27 PM
sorry for that smilie

<HTML>
<SCRIPT>
function vincent() {
var1 = document.hello.world.value
var2 = document.hello.dad.value

window.external.AddFavorite(var1,var2);
}
</SCRIPT>

<FORM name="hello">
name: <INPUT type="text" name="world">
url: <INPUT type="text" name="dad"
<INPUT type="button" onclick="javascript:vincent()">

</HTML>

GavinPearce
04-19-2003, 02:41 PM
Lol I guess I didn't make myself clear. I need it to add to the homepage also.

But doesn't matter I got a solution now anyway thanks.

DrDaMour
04-19-2003, 03:08 PM
Originally posted by gavinnet
Lol I guess I didn't make myself clear. I need it to add to the homepage also.



check mate

GavinPearce
04-19-2003, 03:55 PM
I knew u'd say that. Lol ok I'll say your right. But I did request a homepage script, onl when someone else got it wrong as well. Why am I using the word request also, this isn't a script request lol, im talkin to myself now.

Ok ur rite rite im sorry. :p

Seriously now thanks for your help that script is going to go on my new site.

Thank you once again.

Gav.