Reputation: 49
I am looking for a way to get an alert when a certain code is between two specific lines.
Here is the code:
var stage = new swiffy.Stage(document.getElementById('swiffycontainer'),
swiffyobject, {});
stage.setFlashVars("clickTAG=%%CLICK_URL_ESC%%%%DEST_URL%%");
stage.start();
Is there a way to open the webpage and showing an alert if
stage.setFlashVars("clickTAG=%%CLICK_URL_ESC%%%%DEST_URL%%");"
is in the code and not if it is between
swiffyobject, {});
and stage.start();
?
Upvotes: 0
Views: 117
Reputation: 8166
Assuming you're running your code in a browser env. I guess there's no easy way for you to do that. You can however:
stage.setFlashVars
with your implementation and intercept whether the method has been called with a specific parameter value. This will however not tell you if the code is executed before stage.start() or not.script
tag in the page, you can select that script tag, read its content and parse it (quick example here: http://jsfiddle.net/9vudjwba/). Both approaches looks really overkill to me. What problem are you trying to solve by doing that?
Upvotes: 0
Reputation: 29287
If this script is inside page but not in external script (other file than the page file) you can do like this:
$(function() {
var script = $('script:contains(var stage = new swiffy.Stage(document.getElementById)');
alert(script.length);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
var stage = new swiffy.Stage(document.getElementById('swiffycontainer'),
swiffyobject, {});
stage.setFlashVars("clickTAG=%%CLICK_URL_ESC%%%%DEST_URL%%");
stage.start();
</script>
For the second check, you need to use Regex
and it more complicated.
Upvotes: 1