Link to home
Create AccountLog in
Avatar of Mike Waller
Mike WallerFlag for United States of America

asked on

saving a script source result into a variable

I am calling a javascript that returns a string of data. So the code looks like <script src='[big url of custom data]'></script> and this then drops a string of text on the screen (in this case a latest tweet). The issue is that I want the text to be a link. I know I cannot do <a href=''><script src=''></script></a>  but that is the result I am after. I want to turn the returned value into a link. I already have what it should point to.

Any ideas experts?
SOLUTION
Avatar of Russ Suter
Russ Suter

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Mike Waller

ASKER

I need to be able to save the string into a variable in order to parse it. e.g. var = 'the returned value of the script above'. Then I can parse foo. But first I need to make the foo variable
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
I know basic js, should have specified this. The issue is that I do not have the values to set a variable. I have only a third-party script to call an API via a script src value. The upshot is calling the third party script does not return variables, per se, but returns a value that is dropped on the page. Make sense? Sorry I don't have code, but this is theoretical at this point. The following does not work, bit it illustrates my issue:

All I do is call a third part script. I don't have to write js in this script. I just paste a script call.. I wish I could do something like 'var foo=<script-that-is-a-black-box-and-returns-a-string-placing-it-on-a-web-page>' and then do something with foo.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Thanks!