WriteButton
-
Can someone explain the use of this javascript function.
function WriteButton(lftimg, rtimg, bgimg, text, href, onclick)
{
var szBttnHtml = "<style>" +
"a.button {margin: 0 10px 0 5px;position: relative;bottom: 2px;text-decoration: none;color: #FFF;font-size: 12px;font-weight: bold;}" +
"a.button:hover {text-decoration: underline;}" +
"</style>" +
"<table border='0' cellpadding='0' cellspacing='0'>" +
"<tr><td style='padding: 0px 0px 0px 0px;font-size:1'>" +
"<img src='" + lftimg + "'></td>" +
"<td style='padding: 0px 0px 0px 0px;font-size:1;background-repeat: repeat-x' background='" + bgimg + "'>" +
"<a href='" + href + "' class='button' >" + text + "</a></td>" +
"<td style='padding: 0px 0px 0px 0px;font-size:1'>" +
"<img src='" + rtimg + "'>" +
"</td></tr></table>";
document.write(szBttnHtml);
}Found http://www.unyte.net/js/common.js linked from http://www.unyte.net/download/index.php .
I found this because I have opera turn off javascript by default and I couldnt' download that app. Anyway, amusingly enough, thedailywtf site uses a very enterprisey forum (for a site that pokes fun at enterprisey things it's rather ironic I think) and the first couple of times i tried to post it didn't work because js and such was turned off. God damned web 2.0.
thedailywtf is the real wtf
-
Idea: okay
Implementation: fucked
-
Seems obvious that this function creates the HTML required to place and format a "button" (really just a strictly formatted table with a link inside) with just a few parameters. Ensures that if you make a change to one buttons, all buttons will change in the same way. It's just a shortcut, though arguably it shouldn't be JavaScript that handles this kind of repetition but rather in whatever produced this document.