DOM access

Javascript coding ..

Moderators: macek, egami, gesf

User avatar
ruturajv
php-forum Super User
php-forum Super User
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

DOM access

Postby ruturajv » Wed Nov 16, 2005 11:37 pm

this is a strange requirement, I don't really know how to grab it from DOM,

there is a page that I own pageA where I call js code from other website
pageA

Code: Select all

....
<script src="http://somesite.com/code.js" type="text/javascript"></script>
...
// I want to put some code here...


http://somesite.com/code.js

Code: Select all

function abcd (xyz) {
}


now I want to put some code in PageA
which can find if the function abcd is defined or not

something like

Code: Select all

if (window.abcd) {
   //found
} else {
   //not found
}


but this doesn't work...

Any DOM masters around ???

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Postby Alexej Kubarev » Fri Nov 18, 2005 12:07 pm

how about something like this?

Code: Select all

function function_exists(func)
{
  if (window.func && (typeof window.func=="function"))
  {
    return true;
  }
  else
  {
    return false;
  }
}
Last edited by Alexej Kubarev on Fri Nov 25, 2005 1:05 am, edited 1 time in total.

User avatar
ruturajv
php-forum Super User
php-forum Super User
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

Postby ruturajv » Thu Nov 24, 2005 7:24 pm

hey,
my first solution actually works,,,
it seems i must have had screwed somewhere earlier.


Return to “JavaScript”

Who is online

Users browsing this forum: No registered users and 2 guests

cron