Sorry to ask this while others have too, but the answers for them didn't work for me and I really know nothing when it comes to JS.
I have a portfolio page that had an onload so that the first image of the thumbnails would automatically load with the page. Worked fine. I added some bells and whistles and now it doesn't work. The bells and whistles being a NiftyCorner JS and an expandable menu. The menu works, but the other two, both with the onload command won't work. I've tried a semicolon between them in all the possible configurations that I can think of and yet no luck. Here's the code...let me know if you need this to be live and I'll push it.
Thanks in advance!!!
Code:
<style type="text/css"></style>
<link rel="stylesheet" type="text/css" href="css/design.css" />
<script language="JavaScript" type="text/JavaScript"></script>
<script type="text/javascript" src="niftycube.js"></script>
<script type="text/javascript"> window.onload=function(){Nifty("div#p7TMM_1","big" );}</script>
<link href="p7tmm/p7TMM10.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="p7tmm/p7TMMscripts.js"></script>
<script language="JavaScript" type="text/JavaScript">
<!--
//This is the script to take querystrings from the URL and convert them into
//a Javascript array. "?search=whatever" becomes querystring["search"]
//this loads the portion of the url containing the querystring, and also
//decodes any special character codes
var que = unescape(location.search);
//gets value of querystring
var que = que.substring(que.lastIndexOf("=") + 1);
var layer = 'Div' + que
//toggle between layers - on/off
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
var obj = document.layers ? document.layers[szDivID] :
document.getElementById ? document.getElementById(szDivID).style :
document.all[szDivID].style;
obj.visibility = document.layers ? (iState ? "show" : "hide") :
(iState ? "visible" : "hidden");
}
//-->
</script>
</head>
<body onload="javascript: toggleBox(layer,1);">
And you just add the function to the head along with all the other functions
like
Code:
<script language="JavaScript" type="text/JavaScript">
<!--
//This is the script to take querystrings from the URL and convert them into
//a Javascript array. "?search=whatever" becomes querystring["search"]
//this loads the portion of the url containing the querystring, and also
//decodes any special character codes
var que = unescape(location.search);
//gets value of querystring
var que = que.substring(que.lastIndexOf("=") + 1);
var layer = 'Div' + que
//toggle between layers - on/off
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
var obj = document.layers ? document.layers[szDivID] :
document.getElementById ? document.getElementById(szDivID).style :
document.all[szDivID].style;
obj.visibility = document.layers ? (iState ? "show" : "hide") :
(iState ? "visible" : "hidden");
}
function onloadFunctions(){
FirstFunction();
SecondFunction();
}
//-->
</script>
FirstFunction(); should then be replaced by toggleBox(layer,1);
and SecondFunction(); by the other functions that you wanna execute (or ,I guess, in your case - same function with different arguments)
The image still isn't loading with the page and the corners still don't curve...that is until I click on the first thumbnail, then the corners curve. I've played around with the location of the function, including within the one above the body, but not having any luck. Here's the code as of now:
Code:
<style type="text/css"></style>
<link rel="stylesheet" type="text/css" href="css/design.css" />
<script language="JavaScript" type="text/JavaScript"></script>
<script type="text/javascript" src="niftycube.js"></script>
<!--<script type="text/javascript"> window.onload=function(){Nifty("div#p7TMM_1","big" );}</script>-->
<link href="p7tmm/p7TMM10.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="p7tmm/p7TMMscripts.js"></script>
<script language="JavaScript" type="text/JavaScript">
<!--
//This is the script to take querystrings from the URL and convert them into
//a Javascript array. "?search=whatever" becomes querystring["search"]
//this loads the portion of the url containing the querystring, and also
//decodes any special character codes
var que = unescape(location.search);
//gets value of querystring
var que = que.substring(que.lastIndexOf("=") + 1);
var layer = 'Div' + que
//toggle between layers - on/off
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
var obj = document.layers ? document.layers[szDivID] :
document.getElementById ? document.getElementById(szDivID).style :
document.all[szDivID].style;
obj.visibility = document.layers ? (iState ? "show" : "hide") :
(iState ? "visible" : "hidden");
}
function onloadFunctions(){
toggleBox(layer,1);
Nifty("div#p7TMM_1","big" );
}
//-->
</script>
</head>
<body onload="onloadFunctions();">
<div id="header"><a href="index.html"><img src="images/faust_logo.jpg" alt="Faust Logo" width="240" height="129" /></a></div>
I'll FTP the site tonight and post a link later if it helps. Thanks again.
Did you consider using an addLoadEvent listener instead of body onload?
For example:
Code:
addLoadEvent(
function() {
var a = "value1";
var b = "value2";
function1(a);
function2(b);
}
)
//then in your .js file...
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
That way you can have multiple onload events and not tie them to the body element. In fact, I believe you can have onloads called from multiple included files using this method. The function in the .js file just adds the new commands to the list to be run onload.
OK, on second look of your code I noticed you have a window.onload up in your .js includes. So, the rounded corners that are created using that function are being ignored when you do your eventual body onload. add both of the functions like you put in your response to me to the add load event and it might work. I am curious though why you need javascript to get the rounded corners to work? I would think style alone should work.
Thanks, but I'm still not having any luck. The first image doesn't load and the corners don't curve. As I mentioned, I do not know JS. I am taking the bits and pieces of code for each action and putting it into my page's code. Aside from the corners being created in CSS instead of JS, could you explain where the addLoadEvent would go? This is what I have so far:
Code:
<link rel="stylesheet" type="text/css" href="css/design.css" />
<script language="JavaScript" type="text/JavaScript"></script>
<script type="text/javascript" src="portfolio.js"></script>
<script type="text/javascript" src="niftycube.js"></script>
<!--<script type="text/javascript"> window.onload=function(){Nifty("div#p7TMM_1","big" );}</script>-->
<link href="p7tmm/p7TMM10.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="p7tmm/p7TMMscripts.js"></script>
<script language="JavaScript" type="text/javascript">
addLoadEvent(
function() {
toggleBox(layer,1);
Nifty(div#p7TMM_1, big );
}
)
</script>
<script language="JavaScript" type="text/JavaScript">
<!--
//This is the script to take querystrings from the URL and convert them into
//a Javascript array. "?search=whatever" becomes querystring["search"]
//this loads the portion of the url containing the querystring, and also
//decodes any special character codes
var que = unescape(location.search);
//gets value of querystring
var que = que.substring(que.lastIndexOf("=") + 1);
var layer = 'Div' + que
//toggle between layers - on/off
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
var obj = document.layers ? document.layers[szDivID] :
document.getElementById ? document.getElementById(szDivID).style :
document.all[szDivID].style;
obj.visibility = document.layers ? (iState ? "show" : "hide") :
(iState ? "visible" : "hidden");
}
//-->
</script>
</head>
<body>
I'm a frustrated student on a tight time line so I really appreciate the help.
I want to thank everyone for their help on this. I've tried both the above scripts, from jpavlik and Sciliano and I can get the curves to show, but the first image still won't come up unless the thumbnail is clicked. I had this working before and checked all the code with the prior version and nothing has changed. Here is the link to the site:
It's not fully polished and not quite ready for prime time since I'm stuck on this js issue, but to get to the page I'm debugging in the menu click "Design" and then "Print Design".
Thanks again for all your help...this is why I prefer print design over Web design.
No, if you read my post, I stated that I tried both and I could get the curves to work, but the image still didn't load with the page. Don't take it personally, I've tried every suggestion provided. If you'd like, I'll go back in and switch it to yours to show you what I mean.