teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

js内容の更新

2016/08/28 03:37

投稿

shikasama
shikasama

スコア163

title CHANGED
File without changes
body CHANGED
@@ -1,15 +1,39 @@
1
1
  観覧ありがとうございます.
2
2
 
3
+ asp.net mvc4 ,C#でプロジェクトの改修をしています.
3
4
  外部jsファイルから別の外部jsファイルの関数を呼び出したいです,
5
+ ご教示ください.
4
6
 
7
+
5
8
  調べて以下の方法を試しましたがうまくできませんでした.
6
9
 
7
- hoge.js
8
10
 
11
+ ```javascript
12
+ ###hoge.js
9
- function hogefunction() {
13
+ function hogefunction(form) {
10
14
  document.write("<script type='text/javascript' src='piyo.js'></script>");
11
- window.onload = function(){piyofunction();};
15
+ window.onload = function(){piyofunction(form, url);};
12
16
  }
17
+ ```
13
18
 
19
+ 詳しいコードについては会社からでないと見れないので今はわかりません.
20
+ 申し訳ありません.
21
+ 覚えている限り下記に示します.
14
22
 
23
+ ```javascript
24
+ function piyo.js(form,url) {
25
+ // フォームとurlを指定してwindow.openでurl先を開く処理.
26
+ window.open(url);
27
+ }
28
+ ```
29
+ hoge.jsを使用しているhtmlは
15
- ご教示ください.
30
+ ```html
31
+ <head>
32
+ // 略
33
+ <script type="text/javascript" src="../Scripts/hoge.js"></script>
34
+ </head>
35
+ <body>
36
+ // 略
37
+ <input type="button" value="button" onClick="hogefunction(document.forms[0], '../Views/a.cshtml')">
38
+ </body>
39
+ ```