0

I have 2 files that should be connected.

file.php and page.html

file.php contain this code below:

 document.writeln('< script src="https://www.googletagservices.com/tag/js/gpt.js">
  googletag.pubads().definePassback('/11322282/48fashion.com//300x250', [300, 250]).set("page_url","http://48fashion.com/").display();
< /script>');

page.html contain this code below:

< html > <br>
&nbsp;&nbsp; < head>  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;< script  src="file.php"  type="text/javascript" > < /script> 
<br>
&nbsp;&nbsp;< /head> 


< body> <br>

< /body> <br>

< /html>

Now when I refresh the page.html I received this error message "Uncaught SyntaxError: Invalid or unexpected token"

No, I see that loading a js src with another js src is not working. How make it work?

5
  • You try to insert using document.writeln javascript code but you don't wrap it inside <script>..</script> tags Commented Oct 15, 2016 at 8:02
  • I updated the code, please check again. Commented Oct 15, 2016 at 8:18
  • But that's not valid code, you don't close script tag. Now, what is the real code you are using? We cannot help you to catch synthax error if you just post some random code. And see Samir's answer, because this is a valid point, you have mismatching quotes Commented Oct 15, 2016 at 8:20
  • I'm sorry about that, I though it was added but when I updated stack overflow filtered it. I didn't noticed that. That should have a closing tag. Commented Oct 15, 2016 at 8:27
  • BUT that's still not the code you are using or it is still wrong because a script with src attribute just ignores its content. Anyway, you have fixed your issue... :) Commented Oct 15, 2016 at 8:36

3 Answers 3

2

sorry i can't make comment so here its, just change the single quote to double quote after definePasspack

Sign up to request clarification or add additional context in comments.

2 Comments

That could be an answer... ;)
ok again change the single quote in definePassback("/11322282/48fashion.com//300x250", to double quote and add </script> of end of statement.
1

Try this

document.writeln('< script src="https://www.googletagservices.com/tag/js/gpt.js"> googletag.pubads().definePassback("/11322282/48fashion.com//300x250", [300, 250]).set("page_url","http://48fashion.com/").display(); < /script>');

you had used wrong quote on definePassBack

Comments

1

In this case you should escape the single or the double quotes within the write line.

document.writeln(
        '<script src="https://www.googletagservices.com/tag/js/gpt.js">
            googletag.pubads().definePassback(\'/11322282/48fashion.com//300x250\',
                [300, 250]).set("page_url","http://48fashion.com/").display();
        </script>');

Or put "/11322282/48fashion.com//300x250" between double quotes.

1 Comment

PHP extension works fine even code is javascript and correct that's the only code I produced in php file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.