How do I use jquery to test for a script or element in the head of a page?

I want to create a page that takes one input, a URL, and then reads the page referenced in the URL and checks a few things:
Is there a script tag in the head whose SRC contains a link to a given site?
Are there any divs in the body whose class name beginx with xyz?

So basically it would be  a form with a text field and a submit button. The generated page would be a report listing the existence or absence of the items in the list above.

Is this something jquery could do?
Who is Participating?
Is the URL passed will be on the same domain or not ?
Same domain :
Put the URL into an IFRAME and use :
var iFrameDoc = $("#myIframe").get(0).contentWindow.document;
var scripts = iFrameDoc.scripts;
var siteToMatch = /;

for(var i = 0; i < scripts.length; i++) {
  if (scripts[i].src ~= siteToMatch) {

var classToMach = "xyz";
var divs = jQuery([]).pushStack( iFrameDoc.getElementsByTagName("div") ).filter("className ^=" + classToMatch);

Open in new window

Other domain :
Use the $.get function to retrieve the page. Into the callback function use regular expressions to find what you need.
(Mostly as suggested by AlokJain)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.