הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   עזרה בBBCODE חייב דחוף (https://hosts.co.il/forums/showthread.php?t=52302)

smilie 18-08-07 15:18

עזרה בBBCODE חייב דחוף
 
בניתי BBCODE פשוט אני צריך עזרה איך לסדר כמה דברים

אני צריך לעשות שנגיד והוא מדגיש את הטקסט ואז לוחץ על כפתור אז זה יחליף את הטקסט המודגש בדוגמא:
הטקסט אראה "יקיר המלך"
ואני רוצה להדגיש את המילה
"המלך"
אז זה יהפוך לככה
יקיר [BOLD]המלך[BOLD]

עריכה:
זה הקוד JS
PHP קוד:

function add_emoticon(text) {
    
document.new_topic.body.value  += text;
    
document.new_topic.body.focus();
}

function 
add_bbcode(text,attrib) {
    if(
attrib != undefined) {
        
attrib "=" attrib;
    }
    else
    {
        
attrib "";
    }
    
document.new_topic.body.value += "[" text attrib "]Text[/" text "]";
    
document.new_topic.body.focus();


הנה מה שבניתי
http://www.overws.com/yakird.html

Daniel 18-08-07 18:54

יש לי פונקציה שמצאתי שתומכת בכל הדפדפנים, הממ,
לקח לי המון זמן למצוא פונקציה שתומכת בכל הדפדפנים,
אני ממש לא בטוח שזאת זאת,
PHP קוד:

function GetSelectedelementID )
{

var 
obj document.getElementByIdelementID );
if( !
obj )
throw 
"Element " elementID " not found!";

// Netscape, Mozilla, Firefox
if( typeof(obj.selectionStart) != "undefined" )
{

obj.focus();
var 
start_selection obj.selectionStart;
var 
end_selection obj.selectionEnd;
if (
end_selection start_selection)
{
var 
temp end_selection;
end_selection start_selection;
start_selection temp;
}

return (
obj.value).substring(start_selectionend_selection);

}

// Internet Explorer
if( obj.createTextRange )
{

obj.focusobj.caretPos );
obj.caretPos document.selection.createRange().duplicate();

return 
obj.caretPos.text;

}



תבדוק שוב ליתר ביטחון.


כל הזמנים הם GMT +2. הזמן כעת הוא 06:39.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ