Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About javascript: void (0); #2887

Closed
muh-ramadhan opened this issue Apr 26, 2020 · 3 comments
Closed

About javascript: void (0); #2887

muh-ramadhan opened this issue Apr 26, 2020 · 3 comments

Comments

@muh-ramadhan
Copy link

how to handle it?
in codeigniter version 3 for example I use
<a href="#" data-menu="menu-main"></a>
it functions as it should not refresh the page.
But in codeigniter version 4 lines of code href = "#" refreshes the page. so I changed it to
<a href="javascript"void(0)" data-menu="menu-main"></a> to function without having to refresh the page.

But the problem is javascript: void (0); violates HTTPS Content Security Policy on CSP-enabled (Content Security Policy).

@muh-ramadhan
Copy link
Author

CodeIgniter 4.0.2
Google Chrome Version 81.0.4044.122
Run Local Deveploment and Shared Hosting

@jlamim
Copy link
Contributor

jlamim commented Apr 26, 2020

Wrong: <a href="javascript"void(0)" data-menu="menu-main"></a>

Change to: <a href="javascript:void(0);" data-menu="menu-main"></a>

@muh-ramadhan
Copy link
Author

Wrong: <a href="javascript"void(0)" data-menu="menu-main"></a>

Change to: <a href="javascript:void(0);" data-menu="menu-main"></a>

Sorry typo,
If Use href="#"
This Error Not Toggle data-menu="example"
so must use href=javascript:void(0);
so that data-menu="example" works.
The Case Is Like This, In
app/Config/Routes.php Line 19 $routes->setDefaultController('Welcome');
If I Use a View That in the Routes Setup I Determined This Error Occurs, But It Does Not Apply to Controllers That Are Not Set on Line 19.
To reduce the use of javascript:void(0); In the Default Routes Specified. Because of Content Security Policy Reasons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants