نحن Wangwang بحاجة إلى استدعاء ملفات JS الأخرى. كيف تتعامل معها؟
انظر هذا المثال للرسم العشوائي. في صفحة على النحو التالي:
<html> <head> <title> الرقم العشوائي </title> <script type = "text/javaScript"> // ارسى الاسم بشكل عشوائي </script> </head> <body> <porm> <input type = "button" style = 'font-size: 40px' value = "start" onClick = "start ()" onClick = "STOP () ؛"> </part> <br> <font color = "blue" style = 'font-size: 150px' id = "num"> </font> <br> </body> </html>
يمكننا وضع JS في ملف آخر ، مثل A.JS في المجلد الحالي.
صفحة HTML كما يلي:
<html> <head> <title> الرقم العشوائي </title> <script type = "text/javaScript" src = "A.JS"> </script> </head> <body> <porm> <port> <torm> <turny type = "button" style = "font-size: 40px 'value =" start "onclick =" start () onClick = "STOP () ؛"> </part> <br> <font color = "blue" style = 'font-size: 150px' id = "num"> </font> <br> </body> </html>
A.JS
var errorstring = "الرجاء إدخال عدد صحيح موجب. // max ، global variable document.getElementById ("num"). innerhtml = arr [parseint (max * math.random ())]هذا كل شيء.
بالطبع ، يمكنك أيضًا وضع A.JS على الويب ثم الرجوع إليه على النحو التالي.
<html> <head> <title> الرقم العشوائي </title> <script type = "text/javaScript" src = "http: // localhost: 8080/test/js/random1.js"> </script> </head> <body> <port> <form> <pontr type = "button" = "font-size: type = "button" style = 'font-size: 40px' value = "stop" onClick = "STOP () ؛
ما سبق هو طريقة تقديم (استدعاء) ملف JS الذي قدمه لك المحرر. آمل أن يكون ذلك مفيدًا لك. إذا كان لديك أي أسئلة ، فيرجى ترك رسالة لي وسوف يرد المحرر إليك في الوقت المناسب. شكرا جزيلا لدعمك لموقع wulin.com