/    Sign up×
Community /Pin to ProfileBookmark

Functions work in FF not IE7

Here is my code.

[CODE]String.prototype.trim = function() {
return this.replace(/^s+|s+$/g,””);
}
String.prototype.ltrim = function() {
return this.replace(/^s+/,””);
}
String.prototype.rtrim = function() {
return this.replace(/s+$/,””);
}
String.prototype.htmltags = function () {
return this.replace(/</?[^>]+(>|$)/g, “”);
}

function digg() {
var base_url = ‘http://digg.com/submit?’;
var phase = ‘phase=2’;
var article_url = window.location;
var title = document.getElementById(‘story_title’).innerHTML;
var bodytext = snippetwop(document.getElementById(‘bodytext’).innerHTML, 350);
bodytext = bodytext.htmltags();

var url = base_url + phase + ‘&url=’ + article_url + ‘&title=’ + title
+ ‘&bodytext=’ + bodytext;

var newwindow = window.open(url,’Digg! This Story’);
if (window.focus) {newwindow.focus();}
}

function facebook() {
var base_url = ‘http://www.facebook.com/sharer.php?’;
var article_url = window.location.href;
var title = document.getElementById(‘story_title’).innerHTML;

var url = base_url + ‘u=’ + article_url + ‘&t=’ + title;

var newwindow = window.open(url,’Facebook!’);
}

function snippetwop(text, length, tail) {
var length = typeof(length) != ‘undefined’ ? length : 64;
var tail = typeof(tail) != ‘undefined’ ? tail : ‘…’;

text = text.trim();
var txtl = text.length;

if(txtl > length) {
for(var i=1; text[length-i]!=” “; i++) {
if(i == length) {
return text.substr(0,length) + tail;
}
}
for(; text[length-i]==”,” || text[length-i]==”.” || text[length-i]==” “; i++) {;}
text = text.substr(0,length-i+1) + tail;
}
return text;
}[/CODE]

Help MUCH appreciated

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@KorNov 28.2007 — What exactly does not work?
×

Success!

Help @no0n spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...