如何通过URL运行Javascript代码?

时间:2015-09-23 17:30:49

标签: javascript

我想通过网址运行Javascript代码。

所以,让我说我有这个代码:

<script type='text/javascript'>var nstParams = {pub: ' 9084232', pla: '9048223', ad_type: 'popup', numOfTimes: 3, duration: 24, period: 'hour'};</script><script type="text/javascript" src="http://cdn.clic2pub.com/js/file.1.js"></script>

在我的网站中,我无法选择放置Javascript代码,我只能放置一个网址。

我要找的是当用户点击URL时,Javascript代码开始执行。

2 个答案:

答案 0 :(得分:0)

如果真的为真,您只能指定网址而不是脚本,那么您正在寻找使用-(AudioBufferList *) getBufferListFromData: (NSData *) data { if (data.length > 0) { NSUInteger len = [data length]; //NSData *d2 = [data subdataWithRange:NSMakeRange(4, 1028)]; //I guess you can use Byte*, void* or Float32*. I am not sure if that makes any difference. Byte* byteData = (Byte*) malloc (len); memcpy (byteData, [data bytes], len); if (byteData) { AudioBufferList * theDataBuffer =(AudioBufferList*)malloc(sizeof(AudioBufferList) * 1); theDataBuffer->mNumberBuffers = 1; theDataBuffer->mBuffers[0].mDataByteSize =(UInt32) len; theDataBuffer->mBuffers[0].mNumberChannels = 1; theDataBuffer->mBuffers[0].mData = byteData; // Read the data into an AudioBufferList return theDataBuffer; } } return nil; } 伪协议的bookmarklets:基本上:放在href开头的javascript:,并使用URI编码的JavaScript代码跟随它。

直播示例

javascript:

很多更有可能,你可以选择在你找不到的地方包含脚本。哪个好,因为将重要代码放在<a href="javascript:alert('hi%20there');">Click me</a>中是尴尬和困难的。

答案 1 :(得分:0)

这样的事可能有用:

  Dim i As Long, j As Long, Lastrow1 As Long, Lastcol1 As Long
Dim mandatory As String

'Lastrow1 = Sheets("sheet3").Range("A" & Rows.Count).End(xlUp).Row
Lastcol1 = Sheets("sheet3").Cells(1 & Columns.Count).End(xlToLeft).Column
For i = 1 To Lastcol1

Sheets("sheet4").Activate
Lastcol2 = Sheets("sheet4").Cells(1 & Columns.Count).End(xlToLeft).Column
For j = 1 To Lastcol2

If Sheets("sheet3").Cells(2, i).Value = "mandatory" Then
Sheets("sheet3").Activate
Sheets("sheet3").Cells(i, "A").Copy
Sheets("sheet4").Activate
Sheets("sheet4").Cells(j, "A").Select
ActiveSheet.Paste
End If

Next j

Application.CutCopyMode = False
Next i
Sheets("sheet3").Activate
Sheets("sheet3").Range("A1").Select


End Sub