Post by Jay on Jun 26, 2006 19:25:45 GMT -8
Name: This Post Brought To You By:
Preview: click here
Placement: Global Footer
Editing: None
Okay, I thought this might be a good idear since I haven't seen this type of code created. What this does is each time you create a new post, it detects your browser and displays it when you view the thread. Preview is pretty self explanatory. Don't go having too much fun with this.
Currently detects: and (unknown browsers)
Edit: Now with Safari and unknown browser detection. Preview updated to accompany the changes.
Preview: click here
Placement: Global Footer
Editing: None
Okay, I thought this might be a good idear since I haven't seen this type of code created. What this does is each time you create a new post, it detects your browser and displays it when you view the thread. Preview is pretty self explanatory. Don't go having too much fun with this.
Currently detects: and (unknown browsers)
<script type="text/javascript">
<!--
/* This Post Brought To You By:
Created by Jay
*/
function get_navigator() {
var d_value = document.postForm.message.value;
var nav = window.navigator.appName;
var nav_path;
if (nav == 'Microsoft Internet Explorer') {
nav_path = 1;
}
else if (nav == 'Netscape') {
nav_path = 2;
}
else if (navigator.userAgent.indexOf('Opera') != -1) {
var index = navigator.userAgent.indexOf('Opera') + 6;
if (parseInt(navigator.userAgent.charAt(index)) >= 8) {
nav_path = 3;
}
}
else if (navigator.vendor && navigator.vendor.substring(0, 5) == 'Apple') {
nav_path = 4;
}
else {
nav_path = 0;
}
return (d_value.match(/Agen.:(\d+)]/i))? null : document.postForm.message.value += '\n\n\n[Agent:' +nav_path + ']';
}
var the_tab = document.getElementsByTagName('TABLE');
for (var ta = the_tab.length - 1; ta >= 0; ta--) {
var tab_obj = the_tab.item(ta);
if (tab_obj.width == '100%' && tab_obj.cellSpacing == 2 && tab_obj.rows.item(0).cells.item(0).width == '5%') {
if (/Agen.:(\d+)]/m.test(tab_obj.getElementsByTagName('HR').item(0).nextSibling.innerHTML)) {
var navigator_image = document.createElement('IMG');
navigator_image.setAttribute('border', 1);
var navigator_name = document.createElement('FONT');
var app;
switch (RegExp.$1) {
case '1' :
navigator_image.setAttribute('src', 'http://img380.imageshack.us/img380/7131/ie3nv.gif');
app = 'Microsoft Internet Explorer';
break;
case '2' :
navigator_image.setAttribute('src', 'http://img458.imageshack.us/img458/9087/fox8da.gif');
app = 'Mozilla Firefox';
break;
case '3' :
navigator_image.setAttribute('src', 'http://img390.imageshack.us/img390/9941/opera9qe.gif');
app = 'Opera';
break;
case '4' :
navigator_image.setAttribute('src', 'http://img105.imageshack.us/img105/5673/safari7oq.gif');
app = 'Safari';
break;
default :
navigator_image.setAttribute('src', 'http://img105.imageshack.us/img105/2411/unknown2id.gif');
app = 'an unknown browser';
break;
}
var aRow_one = tab_obj.insertRow(1);
var aCell_one = aRow_one.insertCell(0);
aCell_one.appendChild(navigator_image.cloneNode(true));
var aCell_two = aRow_one.insertCell(1);
navigator_name.setAttribute('size', 1);
navigator_name.innerHTML = 'This post brought to you by ' + app;
navigator_name.appendChild(document.createTextNode('.'));
aCell_two.appendChild(navigator_name.cloneNode(true));
tab_obj.getElementsByTagName('HR').item(0).nextSibling.innerHTML = tab_obj.getElementsByTagName('HR').item(0).nextSibling.innerHTML.split('[Agen')[0];
}
}
}
if (document.postForm && document.postForm.message) {
document.postForm.onsubmit = get_navigator;
}
//-->
</script>
Edit: Now with Safari and unknown browser detection. Preview updated to accompany the changes.