Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,038

HOME > PHP > PHP Forum > รบกวนขอทราบวิธีเปลี่ยน title ของ JavaScript alert + message box เมื่อมีการแจ้งเตื่อนต่าง ๆ คับ


[PHP] รบกวนขอทราบวิธีเปลี่ยน title ของ JavaScript alert + message box เมื่อมีการแจ้งเตื่อนต่าง ๆ คับ

 
Topic : 049787



โพสกระทู้ ( 142 )
บทความ ( 0 )



สถานะออฟไลน์



คืออยากเปลี่ยน title ของ message box ตามที่เราต้องการอ่ะคับ
ขอบคุณมากคับ

message box



Tag : PHP, JavaScript, CakePHP

Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-10-05 16:50:32 By : lengza View : 2635 Reply : 5
 

 

No. 1



โพสกระทู้ ( 1,751 )
บทความ ( 0 )



สถานะออฟไลน์


คืออย่างไรอะครับ คุณต้องการเปลี่ยนให้เป็นไปตามสถานะการณ์ คุณก็ต้องเขียน check ละสถานะเลยดิครับ แค่นี้มานก็น่าจะเปลี่ยนให้แล้วนะ
ถ้าผมเข้าใจผิดขออภัยนะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-05 17:46:08 By : SOUL
 

 

No. 2



โพสกระทู้ ( 74,059 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

JavaScript ไม่น่าจะทำได้น่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-05 17:46:30 By : webmaster
 

 

No. 3



โพสกระทู้ ( 11,835 )
บทความ ( 10 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


jAlert หาโลด
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-05 17:51:24 By : PlaKriM
 

 

No. 4



โพสกระทู้ ( 142 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณ ทุกคำตอบคับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-05 17:52:13 By : lengza
 

 

No. 5



โพสกระทู้ ( 615 )
บทความ ( 4 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


Code (JavaScript)
001.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
002.<html xmlns="http://www.w3.org/1999/xhtml">
003.<head>
004.<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
005.<title>Untitled Document</title>
006.</head>
007.<script>
008./**
009.    Title: MessageBox
010.    Purpose: Create and display a message box
011.    Parameters: None
012.    Known Bugs: None
013.    Author: Tyler Heslinga
014.    Browsers Tested: IE, Firefox
015.    Revision History:
016.        * Tyler Heslinga 03/28/2010 - Created
017.*/
018.function MessageBox() {
019. 
020.    var self = this; // Handle loss of 'this' scope
021. 
022.    this.width; // The width you want the message box to have
023.    this.height; // The estimated height of the message box.  This won't be used for actually specifying the height of the message box and is only used for calculating the center of the screen.
024.    this.x; // The current x position of the user's mouse
025.    this.y; // The current y position of the user's mouse
026.    this.xOffSet; // The difference between where the x position of the user's mouse is and where the left side of the div is
027.    this.yOffSet; // The difference between where the y position of the user's mouse is and where the top side of the div is
028. 
029.    // Create elements
030.    this.messageDiv = document.createElement('div');
031.    this.titleDiv = document.createElement('div');
032.    this.titleSpanText = document.createElement('span');
033.    this.titleSpanButton = document.createElement('span');
034.    this.closeButton = document.createElement('input');
035.    this.closeButton.type = 'button';
036.    this.textDiv = document.createElement('div');
037.    this.buttonDiv = document.createElement('div');
038.    this.button = document.createElement("input");
039.    this.button.type = "button";
040. 
041.    // Build dom
042.    this.messageDiv.appendChild(this.titleDiv);
043.    this.titleDiv.appendChild(this.titleSpanText);
044.    this.titleDiv.appendChild(this.titleSpanButton);
045.    this.titleSpanButton.appendChild(this.closeButton);
046.    this.messageDiv.appendChild(this.textDiv);
047.    this.messageDiv.appendChild(this.buttonDiv);
048.    this.buttonDiv.appendChild(this.button);
049. 
050.    /**
051.        Title: show
052.        Purpose: Displays the message box
053.        Parameters: 1. width (REQUIRED) - The width of the message box
054.                    2. height (REQUIRED) - The estimated height of the message box
055.                    3. title (REQUIRED) - The text/html you want to display in the title of the message box
056.                    4. text (REQUIRED) - The text/html you want to display in the body of the message box
057.                    5. button (REQUIRED) - The label for the confirmation button
058.                    6. locX (OPTIONAL) - The x location you would like to display the message box. Default is center screen.
059.                    7. locY (OPTIONAL) - The y location you would like to display the message box. Default is center screen.
060.                    8. messageDivClass (OPTIONAL) - The CSS class you would like to assign the message box div
061.                    9. titleDivClass (OPTIONAL) - The CSS class you would like to assign the title div
062.                    10. textDivClass (OPTIONAL) -  The CSS class you would like to assign the text div
063.                    11. buttonClass (OPTIONAL) - The CSS class you would like to assign the confirmation button
064.        Returns: Nothing
065.        Known Bugs: None
066.        Exceptions Thrown: None
067.        Assumptions: None
068.        Side Affects: None
069.        Revision History:
070.            * Tyler Heslinga 03/28/2010 - Created
071.    */
072.    this.show = function(width, height, title, text, button, locX, locY, messageDivClass, titleDivClass, textDivClass, buttonClass) {
073. 
074.        // Set up width, height, and labels
075.        this.width = width;
076.        this.height = height;
077.        this.titleSpanText.innerHTML = title;
078.        this.textDiv.innerHTML = text;
079.        this.button.value = button;
080.        this.closeButton.value = ' X ';
081. 
082.        // Set up start position of message box
083.        if (!locX) {
084.            this.messageDiv.style.left = this.getCenterX() + 'px';
085.        }
086.        else {
087.            this.messageDiv.style.left = locX + 'px';
088.        } // end if
089. 
090.        if (!locY) {
091.            this.messageDiv.style.top = this.getCenterY() + 'px';
092.        }
093.        else {
094.            this.messageDiv.style.top = locY + 'px';
095.        } // end if
096. 
097.        // Style related set up
098.        this.setMessageDivStyle(messageDivClass);
099.        this.setTitleDivStyle(titleDivClass);
100.        this.setFloatStyle(this.titleSpanText, 'left');
101.        this.setFloatStyle(this.titleSpanButton, 'right');
102.        this.setCloseButtonStyle();
103.        this.setTextDivStyle(textDivClass);
104.        this.setButtonDivStyle();
105.        this.setButtonStyle(buttonClass);
106. 
107.        // Set up event handlers
108.        this.titleDiv.onmousedown = this.drag;
109.        this.titleDiv.onmouseup = this.drop;
110.        this.button.onclick = this.close;
111.        this.closeButton.onclick = this.close;
112. 
113.        // Display message box
114.        var body = document.getElementsByTagName('body').item(0);
115.        body.appendChild(this.messageDiv);
116.        this.messageDiv.style.display = 'block';
117. 
118.    };
119. 
120.    /**
121.        Title: close
122.        Purpose: Hide message box
123.        Parameters: None
124.        Returns: Nothing
125.        Known Bugs: None
126.        Exceptions Thrown: None
127.        Assumptions: None
128.        Side Affects: None
129.        Revision History:
130.            * Tyler Heslinga 03/28/2010 - Created
131.    */
132.    this.close = function() {
133. 
134.        self.messageDiv.style.display = 'none';
135.        self.cleanUp();
136. 
137.    };
138. 
139.    /**
140.        Title: cleanUp
141.        Purpose: Clean up DOM references
142.        Parameters: None
143.        Returns: Nothing
144.        Known Bugs: None
145.        Exceptions Thrown: None
146.        Assumptions: None
147.        Side Affects: None
148.        Revision History:
149.            * Tyler Heslinga 03/28/2010 - Created
150.    */
151.    this.cleanUp = function() {
152. 
153.        self.messageDiv = null;
154.        self.titleDiv = null;
155.        self.titleSpanText = null;
156.        self.titleSpanButton = null;
157.        self.textDiv = null;
158.        self.buttonDiv = null;
159.        self.button = null;
160.        self.closeButton = null;
161. 
162.    };
163. 
164.    /**
165.        Title: move
166.        Purpose: Move the message box when the mouse moves
167.        Parameters: 1. e (REQUIRED) - The event object that called the function passed by some browsers
168.        Returns: Nothing
169.        Known Bugs: None
170.        Exceptions Thrown: None
171.        Assumptions: None
172.        Side Affects: None
173.        Revision History:
174.            * Tyler Heslinga 03/28/2010 - Created
175.    */
176.    this.move = function(e) {
177. 
178.        if (!e) var e = window.event;
179. 
180.        if (e.pageX) {
181.            self.x = e.pageX;
182.            self.y = e.pageY;
183.        }
184.        else if (e.clientX) {
185.            self.x = e.clientX;
186.            self.y = e.clientY;
187.        }
188. 
189.        self.messageDiv.style.left = (self.x - self.xOffSet) + 'px';
190.        self.messageDiv.style.top = (self.y - self.yOffSet) + 'px';
191. 
192.    };
193. 
194.    /**
195.        Title: drag
196.        Purpose: Set up the message box to be moved when the mouse is moved
197.        Parameters: 1. e (REQUIRED) - The event object that called the function passed by some browsers
198.        Returns: Nothing
199.        Known Bugs: None
200.        Exceptions Thrown: None
201.        Assumptions: None
202.        Side Affects: None
203.        Revision History:
204.            * Tyler Heslinga 03/28/2010 - Created
205.    */
206.    this.drag = function(e) {
207. 
208.        if (!e) var e = window.event;
209. 
210.        if (e.pageX) {
211.            self.x = e.pageX;
212.            self.y = e.pageY;
213.        }
214.        else if (e.clientX) {
215.            self.x = e.clientX;
216.            self.y = e.clientY;
217.        }
218. 
219.        document.onmousemove = self.move;
220. 
221.        self.xOffSet = self.x - self.messageDiv.offsetLeft;
222.        self.yOffSet = self.y - self.messageDiv.offsetTop;
223. 
224.    };
225. 
226.    /**
227.        Title: drop
228.        Purpose: Stop moving the message box when the mouse moves
229.        Parameters: None
230.        Returns: Nothing
231.        Known Bugs: None
232.        Exceptions Thrown: None
233.        Assumptions: None
234.        Side Affects: None
235.        Revision History:
236.            * Tyler Heslinga 03/28/2010 - Created
237.    */
238.    this.drop = function() {
239. 
240.        document.onmousemove = function() { };
241. 
242.    };
243. 
244.    /**
245.        Title: getCenterX
246.        Purpose: Find the x location that will allow you to display the message box in the middle of the screen
247.        Parameters: None
248.        Returns: Nothing
249.        Known Bugs: None
250.        Exceptions Thrown: None
251.        Assumptions: None
252.        Side Affects: None
253.        Revision History:
254.            * Tyler Heslinga 03/28/2010 - Created
255.    */
256.    this.getCenterX = function() {
257. 
258.        var scrolledX = 0; // The x offset due to scrolling in the browser window
259.        var widthX = 0; // The width of the browser window
260. 
261.        if (window.pageXOffset) {
262.            scrolledX = window.pageXOffset;
263.        }
264.        else if (document.documentElement && document.documentElement.scrollLeft) {
265.            scrolledX = document.documentElement.scrollLeft;
266.        }
267.        else if (document.body && document.body.scrollLeft) {
268.            scrolledX = document.body.scrollLeft;
269.        } // end if
270. 
271.        if (window.innerWidth) {
272.            widthX = window.innerWidth;
273.        }
274.        else if (document.documentElement && document.documentElement.clientWidth) {
275.            widthX = document.documentElement.clientWidth;
276.        }
277.        else if (document.body && document.body.clientWidth) {
278.            widthX = document.body.clientWidth;
279.        } // end if
280. 
281.        return scrolledX + (widthX - self.width) / 2;
282. 
283.    };
284. 
285.    /**
286.        Title: getCenterY
287.        Purpose: Find the y location that will allow you to display the message box in the middle of the screen
288.        Parameters: None
289.        Returns: Nothing
290.        Known Bugs: None
291.        Exceptions Thrown: None
292.        Assumptions: None
293.        Side Affects: None
294.        Revision History:
295.            * Tyler Heslinga 03/28/2010 - Created
296.    */
297.    this.getCenterY = function() {
298. 
299.        var scrolledY = 0; // The y offset due to scrolling in the browser window
300.        var heightY = 0; // The height of the browser window
301. 
302.        if (window.pageYOffset) {
303.            scrolledY = window.pageYOffset;
304.        }
305.        else if (document.documentElement && document.documentElement.scrollTop) {
306.            scrolledY = document.documentElement.scrollTop;
307.        }
308.        else if (document.body && document.body.scrollTop) {
309.            scrolledY = document.body.scrollTop;
310.        } // end if
311. 
312.        if (window.innerHeight) {
313.            heightY = window.innerHeight;
314.        }
315.        else if (document.documentElement && document.documentElement.clientHeight) {
316.            heightY = document.documentElement.clientHeight;
317.        }
318.        else if (document.body && document.body.clientHeight) {
319.            heightY = document.body.clientHeight;
320.        } // end if
321. 
322.        return scrolledY + (heightY - self.height) / 2;
323. 
324.    };
325. 
326.    /**
327.        Title: setMessageDivStyle
328.        Purpose: Set up the style for the overall message box div
329.        Parameters: 1. cssClass (OPTIONAL) - The CSS class you would like the message box div to have
330.        Returns: Nothing
331.        Known Bugs: None
332.        Exceptions Thrown: None
333.        Assumptions: None
334.        Side Affects: None
335.        Revision History:
336.            * Tyler Heslinga 03/28/2010 - Created
337.    */
338.    this.setMessageDivStyle = function(cssClass) {
339. 
340.        if (!cssClass) {
341.            // Default style
342.            self.messageDiv.style.fontFamily = 'Calibri';
343.            self.messageDiv.style.backgroundColor = '#EEEEEE';
344.            self.messageDiv.style.border = '2px solid black';
345.            self.messageDiv.style.cursor = 'default';
346.        }
347.        else {
348.            self.messageDiv.className = cssClass;
349.        } // end if
350. 
351.        // Style must haves regardless of css properties
352.        self.messageDiv.style.display = 'none';
353.        self.messageDiv.style.position = 'absolute';
354.        self.messageDiv.style.width = self.width + 'px';
355. 
356.    };
357. 
358.    /**
359.        Title: setTitleDivStyle
360.        Purpose: Set up the style for the title div
361.        Parameters: 1. cssClass (OPTIONAL) - The CSS class you would like the title div to have
362.        Returns: Nothing
363.        Known Bugs: None
364.        Exceptions Thrown: None
365.        Assumptions: None
366.        Side Affects: None
367.        Revision History:
368.            * Tyler Heslinga 03/28/2010 - Created
369.    */
370.    this.setTitleDivStyle = function(cssClass) {
371. 
372.        if (!cssClass) {
373.            // Default style
374.            self.titleDiv.style.backgroundColor = '#0066CC';
375.            self.titleDiv.style.color = 'white';
376.        }
377.        else {
378.            self.titleDiv.className = cssClass;
379.        } // end if
380. 
381.        // Style must haves regardless of css properties
382.        self.titleDiv.style.fontSize = '16px';
383.        self.titleDiv.style.padding = '2px';
384.        self.titleDiv.style.fontWeight = 'bold';
385.        self.titleDiv.style.borderBottom = '2px solid black';
386.        self.titleDiv.style.height = '22px';
387. 
388.    };
389. 
390.    /**
391.        Title: setTextDivStyle
392.        Purpose: Set up the style for the text div
393.        Parameters: 1. cssClass (OPTIONAL) - The CSS class you would like the text div to have
394.        Returns: Nothing
395.        Known Bugs: None
396.        Exceptions Thrown: None
397.        Assumptions: None
398.        Side Affects: None
399.        Revision History:
400.            * Tyler Heslinga 03/28/2010 - Created
401.    */
402.    this.setTextDivStyle = function(cssClass) {
403. 
404.        if (!cssClass) {
405.            // Default style
406.            self.textDiv.style.fontSize = '14px';
407.        }
408.        else {
409.            self.textDiv.className = cssClass;
410.        } // end if
411. 
412.        // Style must haves regardless of css properties
413.        self.textDiv.style.padding = '4px';
414.        self.textDiv.style.marginBottom = '16px';
415. 
416.    };
417. 
418.    /**
419.        Title: setButtonDivStyle
420.        Purpose: Set up the style for the div which contains the confirmation button
421.        Parameters: None
422.        Returns: Nothing
423.        Known Bugs: None
424.        Exceptions Thrown: None
425.        Assumptions: None
426.        Side Affects: None
427.        Revision History:
428.            * Tyler Heslinga 03/28/2010 - Created
429.    */
430.    this.setButtonDivStyle = function() {
431. 
432.        self.buttonDiv.style.textAlign = 'center';
433.        self.buttonDiv.style.marginBottom = '8px';
434. 
435.    };
436. 
437.    /**
438.        Title: setCloseButtonStyle
439.        Purpose: Set up the style for the close button
440.        Parameters: None
441.        Returns: Nothing
442.        Known Bugs: None
443.        Exceptions Thrown: None
444.        Assumptions: None
445.        Side Affects: None
446.        Revision History:
447.            * Tyler Heslinga 03/28/2010 - Created
448.    */
449.    this.setCloseButtonStyle = function() {
450. 
451.        self.closeButton.style.fontWeight = 'bold';
452.        self.closeButton.style.backgroundColor = 'red';
453.        self.closeButton.style.color = 'white';
454.        self.closeButton.style.border = '2px solid #009999';
455.        self.closeButton.style.cursor = 'pointer';
456. 
457.    };
458. 
459.    /**
460.        Title: setButtonStyle
461.        Purpose: Set up the style for the confirmation button
462.        Parameters: 1. cssClass (OPTIONAL) - The CSS class you would like the confirmation button to have
463.        Returns: Nothing
464.        Known Bugs: None
465.        Exceptions Thrown: None
466.        Assumptions: None
467.        Side Affects: None
468.        Revision History:
469.            * Tyler Heslinga 03/28/2010 - Created
470.    */
471.    this.setButtonStyle = function(cssClass) {
472. 
473.        if (!cssClass) {
474.            // Default style
475.            self.button.style.border = '2px solid #009999';
476.            self.button.style.cursor = 'pointer';
477.        }
478.        else {
479.            self.button.className = cssClass;
480.        } // end if
481. 
482.    };
483. 
484.    /**
485.        Title: setFloatStyle
486.        Purpose: Sets the CSS float property for an object
487.        Parameters: 1. obj (REQUIRED) - The element you'd like to apply the float style to
488.                    2. style (REQUIRED) - Options include left, right, or none
489.        Returns: Nothing
490.        Known Bugs: None
491.        Exceptions Thrown: None
492.        Assumptions: None
493.        Side Affects: None
494.        Revision History:
495.            * Tyler Heslinga 03/28/2010 - Created
496.    */
497.    this.setFloatStyle = function(obj, style) {
498. 
499.        obj.style.cssFloat = style; // Most Browsers
500.        obj.style.styleFloat = style; // Internet Explorer
501. 
502.    };
503. 
504.}
505.</script>
506.<body>
507.<input type="button" name="aa" id="aa" value="5555555" onclick="javascript:var MsgBox = new MessageBox(); MsgBox.show(300, 150, 'Example Title', 'Example Text', 'Button Text');" />
508.</body>
509.</html>

เครดิดจากเว็บไหนตะกี้ลืมก็อบมา...
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2010-10-05 17:59:53 By : t-monroe
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : รบกวนขอทราบวิธีเปลี่ยน title ของ JavaScript alert + message box เมื่อมีการแจ้งเตื่อนต่าง ๆ คับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)





ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2025 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่